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;_0x11c3b6
','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=/
+
+
+