Built motion from commit d301b742.|2.6.29
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index 2bf5c42..bc9f83e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6df0=['then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','save','destroy','OpenchannelAccounts','end','stack','name','send','mandatoryDispositionPause','map','OpenchannelAccount','type','key','model','query','filters','intersection','attributes','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','show','Pause','keys','rawAttributes','fields','length','include','find','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','params','describe','addDisposition','OpenchannelAccountId','getDispositions','findOne','hasOwnProperty','order','Disposition','removeDispositions','addAnswer','CannedAnswer','removeAnswers','ids','notify','openchannel','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','ListId','isNil','from','Sequelize','from\x20is\x20mandatory','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey','CmList','List','CmContact','OpenchannelApplication','account','applications','Applications','list','orderBy','priority','asc','Contacts','defaults','firstName','lastName','threadId','OpenchannelInteraction','ContactId','contact','messageId','interaction','created','autoclose','push','close','unmanaged','*,*,*,*','UserId','unshift','waitForTheAssignedAgent','queueId','OpenchannelQueue','queue','startRouting','EventManager','addApplications','sequelize','transaction','READ_COMMITTED','bulkCreate','findAndCountAll','getApplications','Contact','User','Owner','fullname','internal','Tags','color','tag','addAgents','omit','spread','emit','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','body\x20is\x20mandatory\x20and\x20not\x20empty','DESC','out','OpenchannelMessage','dataValues','Messages','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/environment','../../config/license/util','redis','./openchannelAccount.socket','register','client','http','request'];(function(_0x56f01f,_0x3e4bb5){var _0xf204db=function(_0x5254a7){while(--_0x5254a7){_0x56f01f['push'](_0x56f01f['shift']());}};_0xf204db(++_0x3e4bb5);}(_0x6df0,0x15d));var _0x06df=function(_0x680821,_0x23e67f){_0x680821=_0x680821-0x0;var _0x3f132c=_0x6df0[_0x680821];return _0x3f132c;};'use strict';var emlformat=require(_0x06df('0x0'));var rimraf=require(_0x06df('0x1'));var zipdir=require(_0x06df('0x2'));var jsonpatch=require(_0x06df('0x3'));var rp=require(_0x06df('0x4'));var moment=require(_0x06df('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x06df('0x6'));var util=require(_0x06df('0x7'));var path=require(_0x06df('0x8'));var sox=require(_0x06df('0x9'));var csv=require(_0x06df('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x06df('0xb'));var squel=require(_0x06df('0xc'));var crypto=require(_0x06df('0xd'));var jsforce=require(_0x06df('0xe'));var deskjs=require(_0x06df('0xf'));var toCsv=require(_0x06df('0xa'));var querystring=require(_0x06df('0x10'));var Papa=require(_0x06df('0x11'));var Redis=require(_0x06df('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x06df('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x06df('0x14'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x06df('0x15'));var licenseUtil=require(_0x06df('0x16'));var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x06df('0x17')]));require(_0x06df('0x18'))[_0x06df('0x19')](socket);var jayson=require('jayson/promise');var client=jayson[_0x06df('0x1a')]['http']({'port':0x232c});var client9002=jayson[_0x06df('0x1a')][_0x06df('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x1d1127,_0xe78dc1,_0x3c575d,_0x36592b){return new BPromise(function(_0x5d764c,_0x3faf70){var _0x7cc169=_0x36592b||client;return _0x7cc169[_0x06df('0x1c')](_0x1d1127,_0x3c575d)[_0x06df('0x1d')](function(_0xd36ac3){logger[_0x06df('0x1e')](_0x06df('0x1f'),_0xe78dc1,_0x06df('0x20'));logger[_0x06df('0x21')](_0x06df('0x22'),_0xe78dc1,_0x06df('0x20'),JSON[_0x06df('0x23')](_0xd36ac3));if(_0xd36ac3[_0x06df('0x24')]){if(_0xd36ac3[_0x06df('0x24')][_0x06df('0x25')]===0x1f4){logger[_0x06df('0x24')](_0x06df('0x1f'),_0xe78dc1,_0xd36ac3[_0x06df('0x24')]['message']);return _0x3faf70(_0xd36ac3[_0x06df('0x24')][_0x06df('0x26')]);}logger[_0x06df('0x24')](_0x06df('0x1f'),_0xe78dc1,_0xd36ac3[_0x06df('0x24')][_0x06df('0x26')]);return _0x5d764c(_0xd36ac3['error'][_0x06df('0x26')]);}else{logger[_0x06df('0x1e')]('OpenchannelAccount,\x20%s,\x20%s',_0xe78dc1,_0x06df('0x20'));_0x5d764c(_0xd36ac3[_0x06df('0x27')][_0x06df('0x26')]);}})[_0x06df('0x28')](function(_0x331b81){logger[_0x06df('0x24')](_0x06df('0x1f'),_0xe78dc1,_0x331b81);_0x3faf70(_0x331b81);});});}function respondWithStatusCode(_0xd9f8c5,_0x52a134){_0x52a134=_0x52a134||0xcc;return function(_0x59ece1){if(_0x59ece1){return _0xd9f8c5[_0x06df('0x29')](_0x52a134);}return _0xd9f8c5[_0x06df('0x2a')](_0x52a134)['end']();};}function respondWithResult(_0x5eaaf9,_0x1de1cd){_0x1de1cd=_0x1de1cd||0xc8;return function(_0x5dc58e){if(_0x5dc58e){return _0x5eaaf9[_0x06df('0x2a')](_0x1de1cd)[_0x06df('0x2b')](_0x5dc58e);}};}function respondWithFilteredResult(_0x2cad6a,_0x36bc16){return function(_0x5c6a9c){if(_0x5c6a9c){var _0x145fb9=typeof _0x36bc16[_0x06df('0x2c')]===_0x06df('0x2d')&&typeof _0x36bc16[_0x06df('0x2e')]===_0x06df('0x2d');var _0x521a80=_0x5c6a9c[_0x06df('0x2f')];var _0x2c03ca=_0x145fb9?0x0:_0x36bc16[_0x06df('0x2c')];var _0x552e1e=_0x145fb9?_0x5c6a9c['count']:_0x36bc16[_0x06df('0x2c')]+_0x36bc16['limit'];var _0x31225a;if(_0x552e1e>=_0x521a80){_0x552e1e=_0x521a80;_0x31225a=0xc8;}else{_0x31225a=0xce;}_0x2cad6a['status'](_0x31225a);return _0x2cad6a[_0x06df('0x30')](_0x06df('0x31'),_0x2c03ca+'-'+_0x552e1e+'/'+_0x521a80)[_0x06df('0x2b')](_0x5c6a9c);}return null;};}function patchUpdates(_0x13bef3){return function(_0x4e70ba){try{jsonpatch['apply'](_0x4e70ba,_0x13bef3,!![]);}catch(_0x24efcb){return BPromise['reject'](_0x24efcb);}return _0x4e70ba[_0x06df('0x32')]();};}function saveUpdates(_0x36f7e0,_0x417731){return function(_0x49820e){if(_0x49820e){return _0x49820e['update'](_0x36f7e0)['then'](function(_0x372e02){return _0x372e02;});}return null;};}function removeEntity(_0x3a84bb,_0x354ca8){return function(_0x2511dd){if(_0x2511dd){return _0x2511dd[_0x06df('0x33')]()[_0x06df('0x1d')](function(){var _0x839831=_0x2511dd['get']({'plain':!![]});var _0x50d4c1=_0x06df('0x34');return db['UserProfileResource'][_0x06df('0x33')]({'where':{'type':_0x50d4c1,'resourceId':_0x839831['id']}})[_0x06df('0x1d')](function(){return _0x2511dd;});})['then'](function(){_0x3a84bb[_0x06df('0x2a')](0xcc)[_0x06df('0x35')]();});}};}function handleEntityNotFound(_0xca3ee1,_0x892d82){return function(_0x27e610){if(!_0x27e610){_0xca3ee1[_0x06df('0x29')](0x194);}return _0x27e610;};}function handleError(_0x1b94e1,_0x4e30c5){_0x4e30c5=_0x4e30c5||0x1f4;return function(_0x3e9f9d){logger[_0x06df('0x24')](_0x3e9f9d[_0x06df('0x36')]);if(_0x3e9f9d[_0x06df('0x37')]){delete _0x3e9f9d[_0x06df('0x37')];}_0x1b94e1[_0x06df('0x2a')](_0x4e30c5)[_0x06df('0x38')](_0x3e9f9d);};}exports['index']=function(_0x58aa39,_0x2a542a){var _0x296922={'include':[{'model':db['Pause'],'as':_0x06df('0x39')}]},_0xfa1203={},_0xfc43a5={'count':0x0,'rows':[]};var _0x675cd8=_[_0x06df('0x3a')](db[_0x06df('0x3b')]['rawAttributes'],function(_0x233b9a){return{'name':_0x233b9a['fieldName'],'type':_0x233b9a[_0x06df('0x3c')][_0x06df('0x3d')]};});_0xfa1203[_0x06df('0x3e')]=_[_0x06df('0x3a')](_0x675cd8,'name');_0xfa1203[_0x06df('0x3f')]=_['keys'](_0x58aa39['query']);_0xfa1203[_0x06df('0x40')]=_[_0x06df('0x41')](_0xfa1203[_0x06df('0x3e')],_0xfa1203[_0x06df('0x3f')]);_0x296922[_0x06df('0x42')]=_['intersection'](_0xfa1203[_0x06df('0x3e')],qs['fields'](_0x58aa39[_0x06df('0x3f')]['fields']));_0x296922[_0x06df('0x42')]=_0x296922[_0x06df('0x42')]['length']?_0x296922[_0x06df('0x42')]:_0xfa1203[_0x06df('0x3e')];if(!_0x58aa39[_0x06df('0x3f')]['hasOwnProperty'](_0x06df('0x43'))){_0x296922[_0x06df('0x2e')]=qs[_0x06df('0x2e')](_0x58aa39['query']['limit']);_0x296922['offset']=qs[_0x06df('0x2c')](_0x58aa39[_0x06df('0x3f')][_0x06df('0x2c')]);}_0x296922['order']=qs[_0x06df('0x44')](_0x58aa39[_0x06df('0x3f')][_0x06df('0x44')]);_0x296922[_0x06df('0x45')]=qs[_0x06df('0x40')](_[_0x06df('0x46')](_0x58aa39[_0x06df('0x3f')],_0xfa1203[_0x06df('0x40')]),_0x675cd8);if(_0x58aa39['query'][_0x06df('0x47')]){_0x296922[_0x06df('0x45')]=_[_0x06df('0x48')](_0x296922[_0x06df('0x45')],{'$or':_['map'](_0x675cd8,function(_0xa242fa){if(_0xa242fa[_0x06df('0x3c')]!==_0x06df('0x49')){var _0x2bc40d={};_0x2bc40d[_0xa242fa[_0x06df('0x37')]]={'$like':'%'+_0x58aa39[_0x06df('0x3f')][_0x06df('0x47')]+'%'};return _0x2bc40d;}})});}_0x296922=_[_0x06df('0x48')]({},_0x296922,_0x58aa39[_0x06df('0x4a')]);var _0x7c7909={'where':_0x296922[_0x06df('0x45')]};return db['OpenchannelAccount'][_0x06df('0x2f')](_0x7c7909)[_0x06df('0x1d')](function(_0x5c92d0){_0xfc43a5[_0x06df('0x2f')]=_0x5c92d0;if(_0x58aa39[_0x06df('0x3f')][_0x06df('0x4b')]){_0x296922['include']=[{'all':!![]}];}return db[_0x06df('0x3b')][_0x06df('0x4c')](_0x296922);})[_0x06df('0x1d')](function(_0x157979){_0xfc43a5[_0x06df('0x4d')]=_0x157979;return _0xfc43a5;})[_0x06df('0x1d')](respondWithFilteredResult(_0x2a542a,_0x296922))['catch'](handleError(_0x2a542a,null));};exports[_0x06df('0x4e')]=function(_0x4126f7,_0x408402){var _0x5e3adc={'raw':![],'where':{'id':_0x4126f7['params']['id']},'include':[{'model':db[_0x06df('0x4f')],'as':_0x06df('0x39')}]},_0x5b0544={};_0x5b0544[_0x06df('0x3e')]=_[_0x06df('0x50')](db[_0x06df('0x3b')][_0x06df('0x51')]);_0x5b0544[_0x06df('0x3f')]=_[_0x06df('0x50')](_0x4126f7[_0x06df('0x3f')]);_0x5b0544[_0x06df('0x40')]=_[_0x06df('0x41')](_0x5b0544[_0x06df('0x3e')],_0x5b0544[_0x06df('0x3f')]);_0x5e3adc[_0x06df('0x42')]=_[_0x06df('0x41')](_0x5b0544[_0x06df('0x3e')],qs['fields'](_0x4126f7[_0x06df('0x3f')][_0x06df('0x52')]));_0x5e3adc[_0x06df('0x42')]=_0x5e3adc[_0x06df('0x42')][_0x06df('0x53')]?_0x5e3adc[_0x06df('0x42')]:_0x5b0544['model'];if(_0x4126f7[_0x06df('0x3f')]['includeAll']){_0x5e3adc[_0x06df('0x54')]=[{'all':!![]}];}_0x5e3adc=_[_0x06df('0x48')]({},_0x5e3adc,_0x4126f7[_0x06df('0x4a')]);return db['OpenchannelAccount'][_0x06df('0x55')](_0x5e3adc)['then'](handleEntityNotFound(_0x408402,null))['then'](respondWithResult(_0x408402,null))['catch'](handleError(_0x408402,null));};exports[_0x06df('0x56')]=function(_0x66d322,_0x493057){return db[_0x06df('0x3b')][_0x06df('0x56')](_0x66d322['body'],{})[_0x06df('0x1d')](function(_0x2b8e68){var _0x3bd138=_0x66d322[_0x06df('0x57')][_0x06df('0x58')]({'plain':!![]});if(!_0x3bd138)throw new Error(_0x06df('0x59'));if(_0x3bd138[_0x06df('0x5a')]===_0x06df('0x57')){var _0x3dc3e5=_0x2b8e68['get']({'plain':!![]});var _0x442745=_0x06df('0x34');return db[_0x06df('0x5b')][_0x06df('0x55')]({'where':{'name':_0x442745,'userProfileId':_0x3bd138[_0x06df('0x5c')]},'raw':!![]})[_0x06df('0x1d')](function(_0x24e7a8){if(_0x24e7a8&&_0x24e7a8[_0x06df('0x5d')]===0x0){return db['UserProfileResource']['create']({'name':_0x3dc3e5[_0x06df('0x37')],'resourceId':_0x3dc3e5['id'],'type':_0x24e7a8[_0x06df('0x37')],'sectionId':_0x24e7a8['id']},{})[_0x06df('0x1d')](function(){return _0x2b8e68;});}else{return _0x2b8e68;}})[_0x06df('0x28')](function(_0x5a075e){logger['error'](_0x06df('0x5e'),_0x5a075e);throw _0x5a075e;});}return _0x2b8e68;})[_0x06df('0x1d')](respondWithResult(_0x493057,0xc9))[_0x06df('0x28')](handleError(_0x493057,null));};exports[_0x06df('0x5f')]=function(_0x1bbe20,_0x39c0fe){if(_0x1bbe20[_0x06df('0x60')]['id']){delete _0x1bbe20[_0x06df('0x60')]['id'];}return db[_0x06df('0x3b')][_0x06df('0x55')]({'where':{'id':_0x1bbe20[_0x06df('0x61')]['id']},'include':[{'model':db[_0x06df('0x4f')],'as':'mandatoryDispositionPause'}]})[_0x06df('0x1d')](handleEntityNotFound(_0x39c0fe,null))[_0x06df('0x1d')](saveUpdates(_0x1bbe20['body'],null))['then'](respondWithResult(_0x39c0fe,null))[_0x06df('0x28')](handleError(_0x39c0fe,null));};exports[_0x06df('0x33')]=function(_0x9d89,_0x3b82da){return db[_0x06df('0x3b')][_0x06df('0x55')]({'where':{'id':_0x9d89[_0x06df('0x61')]['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x3b82da,null))['then'](removeEntity(_0x3b82da,null))[_0x06df('0x28')](handleError(_0x3b82da,null));};exports[_0x06df('0x62')]=function(_0x1b9a4b,_0x4622e9){return db[_0x06df('0x3b')][_0x06df('0x62')]()[_0x06df('0x1d')](respondWithResult(_0x4622e9,null))[_0x06df('0x28')](handleError(_0x4622e9,null));};exports[_0x06df('0x63')]=function(_0x1b3b1e,_0x53f357,_0x1e8101){if(_0x1b3b1e[_0x06df('0x60')]['id']){delete _0x1b3b1e[_0x06df('0x60')]['id'];}return db[_0x06df('0x3b')][_0x06df('0x55')]({'where':{'id':_0x1b3b1e[_0x06df('0x61')]['id']}})['then'](handleEntityNotFound(_0x53f357,null))['then'](function(_0x2ae59f){if(_0x2ae59f){_0x1b3b1e['body'][_0x06df('0x64')]=_0x2ae59f['id'];return db['Disposition']['create'](_0x1b3b1e[_0x06df('0x60')]);}})[_0x06df('0x1d')](respondWithResult(_0x53f357,null))[_0x06df('0x28')](handleError(_0x53f357,null));};exports[_0x06df('0x65')]=function(_0x364353,_0x178fd1,_0x181de5){var _0x18a045={'raw':![],'where':{}};var _0x1c0619={};var _0x5e3882={'count':0x0,'rows':[]};return db[_0x06df('0x3b')][_0x06df('0x66')]({'where':{'id':_0x364353['params']['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x178fd1,null))[_0x06df('0x1d')](function(_0x1cbe8a){if(_0x1cbe8a){_0x1c0619[_0x06df('0x3e')]=_[_0x06df('0x50')](db['Disposition'][_0x06df('0x51')]);_0x1c0619[_0x06df('0x3f')]=_[_0x06df('0x50')](_0x364353['query']);_0x1c0619[_0x06df('0x40')]=_[_0x06df('0x41')](_0x1c0619['model'],_0x1c0619[_0x06df('0x3f')]);_0x18a045[_0x06df('0x42')]=_[_0x06df('0x41')](_0x1c0619[_0x06df('0x3e')],qs[_0x06df('0x52')](_0x364353['query'][_0x06df('0x52')]));_0x18a045['attributes']=_0x18a045[_0x06df('0x42')][_0x06df('0x53')]?_0x18a045[_0x06df('0x42')]:_0x1c0619[_0x06df('0x3e')];if(!_0x364353[_0x06df('0x3f')][_0x06df('0x67')](_0x06df('0x43'))){_0x18a045[_0x06df('0x2e')]=qs['limit'](_0x364353[_0x06df('0x3f')][_0x06df('0x2e')]);_0x18a045[_0x06df('0x2c')]=qs[_0x06df('0x2c')](_0x364353[_0x06df('0x3f')][_0x06df('0x2c')]);}_0x18a045[_0x06df('0x68')]=qs['sort'](_0x364353[_0x06df('0x3f')][_0x06df('0x44')]);_0x18a045['where']=qs['filters'](_[_0x06df('0x46')](_0x364353[_0x06df('0x3f')],_0x1c0619[_0x06df('0x40')]));_0x18a045[_0x06df('0x45')][_0x06df('0x64')]=_0x1cbe8a['id'];if(_0x364353['query'][_0x06df('0x47')]){_0x18a045[_0x06df('0x45')]=_[_0x06df('0x48')](_0x18a045[_0x06df('0x45')],{'$or':_[_0x06df('0x3a')](_0x18a045[_0x06df('0x42')],function(_0x2d8bd3){var _0x32bec3={};_0x32bec3[_0x2d8bd3]={'$like':'%'+_0x364353['query'][_0x06df('0x47')]+'%'};return _0x32bec3;})});}_0x18a045=_[_0x06df('0x48')]({},_0x18a045,_0x364353['options']);return db['Disposition']['count']({'where':_0x18a045[_0x06df('0x45')]})[_0x06df('0x1d')](function(_0x43259a){_0x5e3882[_0x06df('0x2f')]=_0x43259a;if(_0x364353['query'][_0x06df('0x4b')]){_0x18a045[_0x06df('0x54')]=[{'all':!![]}];}return db[_0x06df('0x69')][_0x06df('0x4c')](_0x18a045);})[_0x06df('0x1d')](function(_0x301a5e){_0x5e3882['rows']=_0x301a5e;return _0x5e3882;});}})[_0x06df('0x1d')](respondWithFilteredResult(_0x178fd1,_0x18a045))['catch'](handleError(_0x178fd1,null));};exports['removeDispositions']=function(_0x2032b6,_0x194cab,_0x5460cc){return db[_0x06df('0x3b')][_0x06df('0x55')]({'where':{'id':_0x2032b6['params']['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x194cab,null))[_0x06df('0x1d')](function(_0xdfbdf1){if(_0xdfbdf1){return _0xdfbdf1[_0x06df('0x6a')](_0x2032b6['query']['ids']);}})['then'](respondWithStatusCode(_0x194cab,null))['catch'](handleError(_0x194cab,null));};exports[_0x06df('0x6b')]=function(_0x2798ca,_0x514354,_0x226404){if(_0x2798ca[_0x06df('0x60')]['id']){delete _0x2798ca[_0x06df('0x60')]['id'];}return db[_0x06df('0x3b')]['find']({'where':{'id':_0x2798ca[_0x06df('0x61')]['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x514354,null))[_0x06df('0x1d')](function(_0x3c8e33){if(_0x3c8e33){_0x2798ca[_0x06df('0x60')][_0x06df('0x64')]=_0x3c8e33['id'];return db[_0x06df('0x6c')]['create'](_0x2798ca['body']);}})['then'](respondWithResult(_0x514354,null))['catch'](handleError(_0x514354,null));};exports['getAnswers']=function(_0x45092f,_0x2a319e,_0x43262f){var _0x57c445={'raw':![],'where':{}};var _0x53c861={};var _0xbaeef4={'count':0x0,'rows':[]};return db[_0x06df('0x3b')][_0x06df('0x66')]({'where':{'id':_0x45092f['params']['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x2a319e,null))['then'](function(_0x304f41){if(_0x304f41){_0x53c861[_0x06df('0x3e')]=_[_0x06df('0x50')](db[_0x06df('0x6c')][_0x06df('0x51')]);_0x53c861['query']=_[_0x06df('0x50')](_0x45092f[_0x06df('0x3f')]);_0x53c861[_0x06df('0x40')]=_['intersection'](_0x53c861['model'],_0x53c861[_0x06df('0x3f')]);_0x57c445[_0x06df('0x42')]=_[_0x06df('0x41')](_0x53c861[_0x06df('0x3e')],qs[_0x06df('0x52')](_0x45092f['query'][_0x06df('0x52')]));_0x57c445[_0x06df('0x42')]=_0x57c445[_0x06df('0x42')]['length']?_0x57c445['attributes']:_0x53c861[_0x06df('0x3e')];if(!_0x45092f[_0x06df('0x3f')][_0x06df('0x67')](_0x06df('0x43'))){_0x57c445[_0x06df('0x2e')]=qs['limit'](_0x45092f[_0x06df('0x3f')][_0x06df('0x2e')]);_0x57c445[_0x06df('0x2c')]=qs[_0x06df('0x2c')](_0x45092f['query'][_0x06df('0x2c')]);}_0x57c445['order']=qs[_0x06df('0x44')](_0x45092f[_0x06df('0x3f')]['sort']);_0x57c445[_0x06df('0x45')]=qs['filters'](_[_0x06df('0x46')](_0x45092f['query'],_0x53c861[_0x06df('0x40')]));_0x57c445[_0x06df('0x45')][_0x06df('0x64')]=_0x304f41['id'];if(_0x45092f['query']['filter']){_0x57c445[_0x06df('0x45')]=_['merge'](_0x57c445['where'],{'$or':_[_0x06df('0x3a')](_0x57c445[_0x06df('0x42')],function(_0x45aa06){var _0x461cb1={};_0x461cb1[_0x45aa06]={'$like':'%'+_0x45092f[_0x06df('0x3f')][_0x06df('0x47')]+'%'};return _0x461cb1;})});}_0x57c445=_[_0x06df('0x48')]({},_0x57c445,_0x45092f['options']);return db[_0x06df('0x6c')][_0x06df('0x2f')]({'where':_0x57c445[_0x06df('0x45')]})[_0x06df('0x1d')](function(_0x5bb804){_0xbaeef4[_0x06df('0x2f')]=_0x5bb804;if(_0x45092f['query'][_0x06df('0x4b')]){_0x57c445['include']=[{'all':!![]}];}return db['CannedAnswer'][_0x06df('0x4c')](_0x57c445);})[_0x06df('0x1d')](function(_0x21c1b6){_0xbaeef4['rows']=_0x21c1b6;return _0xbaeef4;});}})[_0x06df('0x1d')](respondWithFilteredResult(_0x2a319e,_0x57c445))[_0x06df('0x28')](handleError(_0x2a319e,null));};exports[_0x06df('0x6d')]=function(_0x4b2903,_0x53f7a0,_0x3787c3){return db['OpenchannelAccount'][_0x06df('0x55')]({'where':{'id':_0x4b2903[_0x06df('0x61')]['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x53f7a0,null))[_0x06df('0x1d')](function(_0x47be9d){if(_0x47be9d){return _0x47be9d[_0x06df('0x6d')](_0x4b2903['query'][_0x06df('0x6e')]);}})[_0x06df('0x1d')](respondWithStatusCode(_0x53f7a0,null))['catch'](handleError(_0x53f7a0,null));};exports[_0x06df('0x6f')]=function(_0x240984,_0x1cefb3,_0x3e2592){var _0x495103={'body':_0x240984[_0x06df('0x60')],'channel':_0x06df('0x70')};var _0x2a0a75=[];var _0x4fcf70=[];var _0x26afbd={};var _0x5722c7=![];return db['CmContact'][_0x06df('0x62')]()[_0x06df('0x1d')](function(_0x548e5a){if(!_0x548e5a){throw new db['Sequelize'][(_0x06df('0x71'))](_0x06df('0x72'));}_0x2a0a75=_[_0x06df('0x73')](_[_0x06df('0x50')](_0x548e5a),[_0x06df('0x74'),'updatedAt']);_0x4fcf70=_[_0x06df('0x73')](_[_0x06df('0x50')](_0x548e5a),['createdAt',_0x06df('0x75'),'CompanyId',_0x06df('0x76')]);if(_0x240984[_0x06df('0x60')]['id']){delete _0x240984[_0x06df('0x60')]['id'];}if(_[_0x06df('0x77')](_0x240984[_0x06df('0x60')][_0x06df('0x78')])){throw new db[(_0x06df('0x79'))][(_0x06df('0x71'))](_0x06df('0x7a'));}if(_[_0x06df('0x77')](_0x240984[_0x06df('0x60')][_0x06df('0x60')])||_0x240984[_0x06df('0x60')][_0x06df('0x60')]===''){throw new db[(_0x06df('0x79'))][(_0x06df('0x71'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x06df('0x77')](_0x240984['body']['mapKey'])){throw new db['Sequelize']['ValidationError'](_0x06df('0x7b')+_0x4fcf70);}if(!_['includes'](_0x4fcf70,_0x240984[_0x06df('0x60')]['mapKey'])){throw new db['Sequelize'][(_0x06df('0x71'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4fcf70);}_0x26afbd[_0x240984['body'][_0x06df('0x7c')]]=_0x240984[_0x06df('0x60')][_0x06df('0x78')];})[_0x06df('0x1d')](function(){return db[_0x06df('0x3b')][_0x06df('0x55')]({'where':{'id':_0x240984[_0x06df('0x61')]['id']},'include':[{'model':db[_0x06df('0x7d')],'as':_0x06df('0x7e'),'include':[{'model':db[_0x06df('0x7f')],'as':'Contacts','where':_0x26afbd,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db[_0x06df('0x80')],'as':'Applications'}]});})[_0x06df('0x1d')](handleEntityNotFound(_0x1cefb3,null))[_0x06df('0x1d')](function(_0x359783){if(_0x359783&&_0x359783['List']){_0x495103[_0x06df('0x81')]=_0x359783;_0x495103[_0x06df('0x82')]=_0x359783[_0x06df('0x83')];_0x495103[_0x06df('0x84')]=_0x359783[_0x06df('0x7e')];_0x495103[_0x06df('0x82')]=_[_0x06df('0x85')](_0x495103[_0x06df('0x82')],[_0x06df('0x86')],[_0x06df('0x87')]);if(_0x495103[_0x06df('0x81')][_0x06df('0x83')]){delete _0x495103['account']['Applications'];}if(_0x495103[_0x06df('0x81')][_0x06df('0x7e')]&&_0x495103[_0x06df('0x81')][_0x06df('0x7e')][_0x06df('0x88')][_0x06df('0x53')]){return _0x495103[_0x06df('0x81')][_0x06df('0x7e')]['Contacts'][0x0];}var _0x3d5293=_[_0x06df('0x89')](_0x240984[_0x06df('0x60')],{'firstName':_0x240984[_0x06df('0x60')][_0x06df('0x78')],'ListId':_0x359783[_0x06df('0x76')]});_0x3d5293[_0x240984[_0x06df('0x60')][_0x06df('0x7c')]]=_0x240984[_0x06df('0x60')][_0x06df('0x78')];return db[_0x06df('0x7f')]['create'](_0x3d5293,{'fields':_0x2a0a75,'raw':!![]});}})[_0x06df('0x1d')](handleEntityNotFound(_0x1cefb3,null))['then'](function(_0x4c07e3){_0x495103['contact']=_0x4c07e3;if(_0x4c07e3){var _0x18cd82={'ContactId':_0x4c07e3['id'],'OpenchannelAccountId':_0x240984[_0x06df('0x61')]['id'],'from':(_0x4c07e3[_0x06df('0x8a')]||'')+'\x20'+(_0x4c07e3[_0x06df('0x8b')]||'')};var _0x42ed25={'OpenchannelAccountId':_0x240984[_0x06df('0x61')]['id'],'closed':![]};if(_0x240984['body'][_0x06df('0x8c')]){_0x42ed25[_0x06df('0x8c')]=_0x240984['body'][_0x06df('0x8c')];return db[_0x06df('0x8d')]['find']({'where':_0x42ed25})[_0x06df('0x1d')](function(_0x100e22){if(_0x100e22){return[_0x100e22,![]];}_0x18cd82[_0x06df('0x8c')]=_0x240984[_0x06df('0x60')][_0x06df('0x8c')];_0x18cd82['externalUrl']=_0x240984[_0x06df('0x60')]['externalUrl'];return db[_0x06df('0x8d')][_0x06df('0x56')](_0x18cd82)[_0x06df('0x1d')](function(_0x11c836){return[_0x11c836,!![]];});});}else{_0x42ed25[_0x06df('0x8c')]=null;}_0x42ed25[_0x06df('0x8e')]=_0x4c07e3['id'];return db[_0x06df('0x8d')][_0x06df('0x55')]({'where':_0x42ed25})['then'](function(_0x43f428){if(_0x43f428){return[_0x43f428,![]];}return db[_0x06df('0x8d')][_0x06df('0x56')](_0x18cd82)[_0x06df('0x1d')](function(_0x3b3d42){return[_0x3b3d42,!![]];});});}})['spread'](function(_0x540599,_0x2e8edd){if(_0x540599){_0x5722c7=_0x2e8edd;if(!_0x2e8edd){var _0x553e36={'from':(_0x495103['contact'][_0x06df('0x8a')]||'')+'\x20'+(_0x495103[_0x06df('0x8f')]['lastName']||'')};if(_0x240984[_0x06df('0x60')][_0x06df('0x8c')]&&_0x240984[_0x06df('0x60')][_0x06df('0x90')]&&_0x240984[_0x06df('0x60')][_0x06df('0x8c')]!=_0x240984[_0x06df('0x60')][_0x06df('0x90')]){_0x553e36[_0x06df('0x8c')]=_0x240984[_0x06df('0x60')][_0x06df('0x90')];}return _0x540599['update'](_0x553e36);}else{return _0x540599;}}})[_0x06df('0x1d')](function(_0x22d5df){_0x495103['interaction']=_0x22d5df[_0x06df('0x58')]({'plain':!![]});_0x495103[_0x06df('0x91')][_0x06df('0x92')]=_0x5722c7;if(_0x495103[_0x06df('0x91')][_0x06df('0x92')]){if(_0x495103[_0x06df('0x81')][_0x06df('0x93')]){_0x495103[_0x06df('0x82')][_0x06df('0x94')]({'id':0x0,'priority':_0x495103[_0x06df('0x82')][_0x06df('0x53')]+0x1,'app':_0x06df('0x95'),'appdata':_0x06df('0x96'),'interval':_0x06df('0x97')});}}return db['OpenchannelMessage']['create']({'body':_0x240984[_0x06df('0x60')]['body'],'OpenchannelAccountId':_0x240984[_0x06df('0x61')]['id'],'OpenchannelInteractionId':_0x22d5df['id'],'direction':'in','ContactId':_0x495103[_0x06df('0x8f')]['id'],'AttachmentId':_0x240984['body']['AttachmentId']});})[_0x06df('0x1d')](function(_0x582e31){_0x495103[_0x06df('0x26')]=_0x582e31;if(!_0x495103[_0x06df('0x91')][_0x06df('0x98')])return;return db['User'][_0x06df('0x55')]({'attributes':['id',_0x06df('0x37')],'where':{'id':_0x495103[_0x06df('0x91')][_0x06df('0x98')]}});})[_0x06df('0x1d')](function(_0x3c7041){if(_0x3c7041){_0x495103[_0x06df('0x82')][_0x06df('0x99')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x3c7041[_0x06df('0x37')]+','+(_0x495103[_0x06df('0x81')][_0x06df('0x9a')]||0xa),'interval':_0x06df('0x97')});}if(!_0x495103[_0x06df('0x91')][_0x06df('0x9b')])return;return db[_0x06df('0x9c')]['find']({'attributes':['id',_0x06df('0x37')],'where':{'id':_0x495103['interaction'][_0x06df('0x9b')]}});})[_0x06df('0x1d')](function(_0x5ed8ab){if(_0x5ed8ab){_0x495103[_0x06df('0x82')][_0x06df('0x99')]({'id':0x0,'priority':0x1,'app':_0x06df('0x9d'),'appdata':_0x5ed8ab['name']+','+(_0x495103[_0x06df('0x81')]['waitForTheAssignedQueue']||0x12c),'interval':_0x06df('0x97')});}return respondWithRpcPromise('Start',_0x06df('0x9e'),_0x495103);})[_0x06df('0x1d')](function(_0x419b9e){respondWithRpcPromise('EventManager',_0x06df('0x9f'),{'event':_0x06df('0x6f'),'message':_0x419b9e},client9002);return _0x419b9e;})[_0x06df('0x1d')](respondWithResult(_0x1cefb3,null))[_0x06df('0x28')](handleError(_0x1cefb3,null));};exports[_0x06df('0xa0')]=function(_0x375e39,_0x99c56c){var _0x96f2bb=_0x375e39[_0x06df('0x61')]['id'];var _0x3d84e0=_0x375e39[_0x06df('0x60')];var _0x2120a3=0xc8;var _0x4be83f=null;return db[_0x06df('0xa1')][_0x06df('0xa2')]({'isolationLevel':db[_0x06df('0xa1')]['Transaction']['ISOLATION_LEVELS'][_0x06df('0xa3')]},function(_0x328c41){return db[_0x06df('0x3b')][_0x06df('0x66')]({'where':{'id':_0x96f2bb},'transaction':_0x328c41})[_0x06df('0x1d')](function(_0x417dd3){if(_0x417dd3){return db[_0x06df('0x80')][_0x06df('0x33')]({'where':{'OpenchannelAccountId':_0x96f2bb},'transaction':_0x328c41})[_0x06df('0x1d')](function(){var _0x276f02=_[_0x06df('0x3a')](_0x3d84e0,function(_0x59a641){_0x59a641['OpenchannelAccountId']=_0x96f2bb;return _0x59a641;});return db[_0x06df('0x80')][_0x06df('0xa4')](_0x276f02,{'transaction':_0x328c41});});}else{_0x2120a3=0x194;_0x4be83f=[];}});})[_0x06df('0x1d')](function(){if(_0x2120a3!==0x194){return db[_0x06df('0x80')][_0x06df('0xa5')]({'where':{'OpenchannelAccountId':_0x96f2bb},'order':_0x06df('0x86')})[_0x06df('0x1d')](function(_0x101a1){_0x4be83f=_0x101a1;});}})[_0x06df('0x28')](function(_0x3e5ad3){_0x2120a3=0x1f4;logger['error'](_0x3e5ad3[_0x06df('0x36')]);if(_0x3e5ad3[_0x06df('0x37')]){delete _0x3e5ad3[_0x06df('0x37')];}_0x4be83f=_0x3e5ad3;})['finally'](function(){if(_0x4be83f===null){_0x99c56c[_0x06df('0x29')](_0x2120a3);}else{if(_0x2120a3===0x1f4){_0x99c56c[_0x06df('0x2a')](_0x2120a3)[_0x06df('0x38')](_0x4be83f);}else{_0x99c56c[_0x06df('0x2a')](_0x2120a3)[_0x06df('0x2b')](_0x4be83f);}}});};exports[_0x06df('0xa6')]=function(_0x22c267,_0x578f6e,_0x2cba6e){var _0x1e5478={};var _0x15aaf0={};var _0x5ec05b;var _0x26a86b;return db[_0x06df('0x3b')][_0x06df('0x66')]({'where':{'id':_0x22c267[_0x06df('0x61')]['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x578f6e,null))[_0x06df('0x1d')](function(_0x2a461a){if(_0x2a461a){_0x5ec05b=_0x2a461a;_0x15aaf0[_0x06df('0x3e')]=_[_0x06df('0x50')](db[_0x06df('0x80')][_0x06df('0x51')]);_0x15aaf0[_0x06df('0x3f')]=_[_0x06df('0x50')](_0x22c267[_0x06df('0x3f')]);_0x15aaf0[_0x06df('0x40')]=_[_0x06df('0x41')](_0x15aaf0[_0x06df('0x3e')],_0x15aaf0['query']);_0x1e5478[_0x06df('0x42')]=_[_0x06df('0x41')](_0x15aaf0['model'],qs[_0x06df('0x52')](_0x22c267[_0x06df('0x3f')][_0x06df('0x52')]));_0x1e5478[_0x06df('0x42')]=_0x1e5478[_0x06df('0x42')][_0x06df('0x53')]?_0x1e5478[_0x06df('0x42')]:_0x15aaf0['model'];_0x1e5478['order']=qs[_0x06df('0x44')](_0x22c267[_0x06df('0x3f')][_0x06df('0x44')]);_0x1e5478[_0x06df('0x45')]=qs[_0x06df('0x40')](_[_0x06df('0x46')](_0x22c267[_0x06df('0x3f')],_0x15aaf0[_0x06df('0x40')]));if(_0x22c267['query'][_0x06df('0x47')]){_0x1e5478[_0x06df('0x45')]=_[_0x06df('0x48')](_0x1e5478['where'],{'$or':_[_0x06df('0x3a')](_0x1e5478[_0x06df('0x42')],function(_0x473aae){var _0x53acfb={};_0x53acfb[_0x473aae]={'$like':'%'+_0x22c267[_0x06df('0x3f')]['filter']+'%'};return _0x53acfb;})});}_0x1e5478=_[_0x06df('0x48')]({},_0x1e5478,_0x22c267[_0x06df('0x4a')]);return _0x5ec05b[_0x06df('0xa6')](_0x1e5478);}})['then'](function(_0x29ba5b){if(_0x29ba5b){_0x26a86b=_0x29ba5b[_0x06df('0x53')];if(!_0x22c267['query'][_0x06df('0x67')]('nolimit')){_0x1e5478['limit']=qs[_0x06df('0x2e')](_0x22c267[_0x06df('0x3f')][_0x06df('0x2e')]);_0x1e5478[_0x06df('0x2c')]=qs['offset'](_0x22c267[_0x06df('0x3f')][_0x06df('0x2c')]);}return _0x5ec05b[_0x06df('0xa6')](_0x1e5478);}})[_0x06df('0x1d')](function(_0xd9b54f){if(_0xd9b54f){return _0xd9b54f?{'count':_0x26a86b,'rows':_0xd9b54f}:null;}})[_0x06df('0x1d')](respondWithResult(_0x578f6e,null))[_0x06df('0x28')](handleError(_0x578f6e,null));};exports['getInteractions']=function(_0x433518,_0x33e520,_0x95caeb){var _0x5b5ad9={'raw':![],'where':{}};var _0x397b87={};var _0x37503d={'count':0x0,'rows':[]};return db[_0x06df('0x3b')][_0x06df('0x66')]({'where':{'id':_0x433518[_0x06df('0x61')]['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x33e520,null))['then'](function(_0x280d67){if(_0x280d67){_0x397b87[_0x06df('0x3e')]=_[_0x06df('0x50')](db[_0x06df('0x8d')][_0x06df('0x51')]);_0x397b87[_0x06df('0x3f')]=_[_0x06df('0x50')](_0x433518['query']);_0x397b87[_0x06df('0x40')]=_['intersection'](_0x397b87['model'],_0x397b87[_0x06df('0x3f')]);_0x5b5ad9['attributes']=_[_0x06df('0x41')](_0x397b87['model'],qs['fields'](_0x433518['query'][_0x06df('0x52')]));_0x5b5ad9['attributes']=_0x5b5ad9['attributes'][_0x06df('0x53')]?_0x5b5ad9['attributes']:_0x397b87['model'];if(!_0x433518['query'][_0x06df('0x67')](_0x06df('0x43'))){_0x5b5ad9['limit']=qs[_0x06df('0x2e')](_0x433518['query']['limit']);_0x5b5ad9['offset']=qs['offset'](_0x433518[_0x06df('0x3f')]['offset']);}_0x5b5ad9[_0x06df('0x68')]=qs[_0x06df('0x44')](_0x433518['query'][_0x06df('0x44')]);_0x5b5ad9[_0x06df('0x45')]=qs[_0x06df('0x40')](_[_0x06df('0x46')](_0x433518[_0x06df('0x3f')],_0x397b87[_0x06df('0x40')]));_0x5b5ad9[_0x06df('0x45')]['OpenchannelAccountId']=_0x280d67['id'];if(_0x433518[_0x06df('0x3f')]['filter']){_0x5b5ad9[_0x06df('0x45')]=_[_0x06df('0x48')](_0x5b5ad9[_0x06df('0x45')],{'$or':_[_0x06df('0x3a')](_0x5b5ad9['attributes'],function(_0x4e32da){var _0x126e3a={};_0x126e3a[_0x4e32da]={'$like':'%'+_0x433518['query'][_0x06df('0x47')]+'%'};return _0x126e3a;})});}_0x5b5ad9=_[_0x06df('0x48')]({},_0x5b5ad9,_0x433518[_0x06df('0x4a')]);return db['OpenchannelInteraction'][_0x06df('0x2f')]({'where':_0x5b5ad9[_0x06df('0x45')]})[_0x06df('0x1d')](function(_0x493796){_0x37503d[_0x06df('0x2f')]=_0x493796;if(_0x433518[_0x06df('0x3f')]['includeAll']){_0x5b5ad9[_0x06df('0x54')]=[{'model':db['CmContact'],'as':_0x06df('0xa7'),'required':![]},{'model':db[_0x06df('0xa8')],'as':_0x06df('0xa9'),'attributes':[_0x06df('0x37'),_0x06df('0xaa'),_0x06df('0xab')],'required':![]},{'model':db['Tag'],'as':_0x06df('0xac'),'attributes':['id',_0x06df('0x37'),_0x06df('0xad')],'where':_0x433518[_0x06df('0x3f')][_0x06df('0xae')]?{'id':_0x433518[_0x06df('0x3f')][_0x06df('0xae')]}:undefined,'required':_0x433518['query'][_0x06df('0xae')]?!![]:![]}];}return db[_0x06df('0x8d')]['findAll'](_0x5b5ad9);})[_0x06df('0x1d')](function(_0x28ab63){_0x37503d[_0x06df('0x4d')]=_0x28ab63;return _0x37503d;});}})[_0x06df('0x1d')](respondWithFilteredResult(_0x33e520,_0x5b5ad9))[_0x06df('0x28')](handleError(_0x33e520,null));};exports['addAgents']=function(_0x2d7199,_0x423782,_0x57a657){return db['OpenchannelAccount'][_0x06df('0x55')]({'where':{'id':_0x2d7199[_0x06df('0x61')]['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x423782,null))[_0x06df('0x1d')](function(_0x4d14c2){if(_0x4d14c2){return _0x4d14c2[_0x06df('0xaf')](_0x2d7199[_0x06df('0x60')][_0x06df('0x6e')],_[_0x06df('0xb0')](_0x2d7199[_0x06df('0x60')],[_0x06df('0x6e'),'id'])||{})[_0x06df('0xb1')](function(_0x441016){for(var _0x55a841=0x0;_0x55a841<_0x2d7199[_0x06df('0x60')]['ids'][_0x06df('0x53')];_0x55a841+=0x1){socket[_0x06df('0xb2')]('userOpenchannelAccount:save',{'UserId':Number(_0x2d7199['body'][_0x06df('0x6e')][_0x55a841]),'OpenchannelAccountId':Number(_0x2d7199[_0x06df('0x61')]['id'])});}return _0x441016;});}})[_0x06df('0x1d')](respondWithResult(_0x423782,null))[_0x06df('0x28')](handleError(_0x423782,null));};exports['removeAgents']=function(_0x3e08db,_0x19acba,_0x5baa4b){return db[_0x06df('0x3b')][_0x06df('0x55')]({'where':{'id':_0x3e08db[_0x06df('0x61')]['id']}})['then'](handleEntityNotFound(_0x19acba,null))['then'](function(_0x203c72){if(_0x203c72){return _0x203c72[_0x06df('0xb3')](_0x3e08db[_0x06df('0x3f')][_0x06df('0x6e')])[_0x06df('0x1d')](function(){if(_[_0x06df('0xb4')](_0x3e08db[_0x06df('0x3f')][_0x06df('0x6e')])){for(var _0x579bec=0x0;_0x579bec<_0x3e08db[_0x06df('0x3f')][_0x06df('0x6e')][_0x06df('0x53')];_0x579bec+=0x1){socket[_0x06df('0xb2')](_0x06df('0xb5'),{'UserId':Number(_0x3e08db[_0x06df('0x3f')][_0x06df('0x6e')][_0x579bec]),'OpenchannelAccountId':Number(_0x3e08db[_0x06df('0x61')]['id'])});}}else{socket['emit'](_0x06df('0xb5'),{'UserId':Number(_0x3e08db['query'][_0x06df('0x6e')]),'OpenchannelAccountId':Number(_0x3e08db[_0x06df('0x61')]['id'])});}});}})[_0x06df('0x1d')](respondWithStatusCode(_0x19acba,null))[_0x06df('0x28')](handleError(_0x19acba,null));};exports[_0x06df('0xb6')]=function(_0x1c9f6b,_0x33fa2f,_0x459a81){var _0x2cbee0={};var _0xb59214={};var _0x4c734c;var _0x5f1a51;return db[_0x06df('0x3b')][_0x06df('0x66')]({'where':{'id':_0x1c9f6b[_0x06df('0x61')]['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x33fa2f,null))[_0x06df('0x1d')](function(_0x11b764){if(_0x11b764){_0x4c734c=_0x11b764;_0xb59214[_0x06df('0x3e')]=_[_0x06df('0x50')](db['User'][_0x06df('0x51')]);_0xb59214[_0x06df('0x3f')]=_[_0x06df('0x50')](_0x1c9f6b[_0x06df('0x3f')]);_0xb59214['filters']=_[_0x06df('0x41')](_0xb59214['model'],_0xb59214[_0x06df('0x3f')]);_0x2cbee0['attributes']=_['intersection'](_0xb59214[_0x06df('0x3e')],qs[_0x06df('0x52')](_0x1c9f6b[_0x06df('0x3f')]['fields']));_0x2cbee0[_0x06df('0x42')]=_0x2cbee0[_0x06df('0x42')][_0x06df('0x53')]?_0x2cbee0[_0x06df('0x42')]:_0xb59214['model'];_0x2cbee0[_0x06df('0x68')]=qs[_0x06df('0x44')](_0x1c9f6b[_0x06df('0x3f')]['sort']);_0x2cbee0['where']=qs[_0x06df('0x40')](_[_0x06df('0x46')](_0x1c9f6b['query'],_0xb59214[_0x06df('0x40')]));if(_0x1c9f6b['query']['filter']){_0x2cbee0[_0x06df('0x45')]=_[_0x06df('0x48')](_0x2cbee0['where'],{'$or':_[_0x06df('0x3a')](_0x2cbee0['attributes'],function(_0x516202){var _0x2fc638={};_0x2fc638[_0x516202]={'$like':'%'+_0x1c9f6b[_0x06df('0x3f')]['filter']+'%'};return _0x2fc638;})});}_0x2cbee0=_[_0x06df('0x48')]({},_0x2cbee0,_0x1c9f6b[_0x06df('0x4a')]);return _0x4c734c[_0x06df('0xb6')](_0x2cbee0);}})[_0x06df('0x1d')](function(_0x3133b9){if(_0x3133b9){_0x5f1a51=_0x3133b9[_0x06df('0x53')];if(!_0x1c9f6b[_0x06df('0x3f')][_0x06df('0x67')]('nolimit')){_0x2cbee0[_0x06df('0x2e')]=qs[_0x06df('0x2e')](_0x1c9f6b[_0x06df('0x3f')][_0x06df('0x2e')]);_0x2cbee0[_0x06df('0x2c')]=qs['offset'](_0x1c9f6b['query'][_0x06df('0x2c')]);}return _0x4c734c[_0x06df('0xb6')](_0x2cbee0);}})[_0x06df('0x1d')](function(_0x3eb57f){if(_0x3eb57f){return _0x3eb57f?{'count':_0x5f1a51,'rows':_0x3eb57f}:null;}})[_0x06df('0x1d')](respondWithResult(_0x33fa2f,null))[_0x06df('0x28')](handleError(_0x33fa2f,null));};exports[_0x06df('0x38')]=function(_0x164506,_0x17d156,_0x550208){var _0x24b6dd,_0x14d9ae,_0x14c0f1;if(_[_0x06df('0x77')](_0x164506[_0x06df('0x60')]['body'])||_0x164506[_0x06df('0x60')][_0x06df('0x60')]===''){throw new db[(_0x06df('0x79'))][(_0x06df('0x71'))](_0x06df('0xb7'));}if(_[_0x06df('0x77')](_0x164506['body']['to'])){}_0x24b6dd=_0x164506[_0x06df('0x60')]['to'];return db[_0x06df('0x3b')]['findOne']({'where':{'id':_0x164506[_0x06df('0x61')]['id']}})[_0x06df('0x1d')](handleEntityNotFound(_0x17d156,null))[_0x06df('0x1d')](function(_0x3d2710){if(_0x3d2710){return db[_0x06df('0x3b')][_0x06df('0x55')]({'where':{'id':_0x3d2710['id']},'include':[{'model':db[_0x06df('0x7d')],'as':'List','include':[{'model':db['CmContact'],'as':_0x06df('0x88'),'where':{[_0x3d2710[_0x06df('0x7c')]]:_0x24b6dd},'limit':0x1,'order':[[_0x06df('0x75'),_0x06df('0xb8')]]}]}]})['then'](handleEntityNotFound(_0x17d156,null))[_0x06df('0x1d')](function(_0x2183f7){if(_0x2183f7&&_0x2183f7[_0x06df('0x7e')]){_0x14d9ae=_0x2183f7[_0x06df('0x58')]({'plain':!![]});if(_0x14d9ae[_0x06df('0x7e')]&&_0x14d9ae[_0x06df('0x7e')][_0x06df('0x88')][_0x06df('0x53')]){return _0x14d9ae['List']['Contacts'][0x0];}return db[_0x06df('0x7f')][_0x06df('0x56')](_['defaults'](_0x164506[_0x06df('0x60')],{'firstName':_0x24b6dd,[_0x2183f7[_0x06df('0x7c')]]:_0x24b6dd,'phone':_0x24b6dd,'ListId':_0x14d9ae['ListId']}));}})[_0x06df('0x1d')](handleEntityNotFound(_0x17d156,null))[_0x06df('0x1d')](function(_0x5aed00){if(_0x5aed00){_0x14c0f1=_0x5aed00;return db[_0x06df('0x8d')][_0x06df('0x55')]({'where':{'ContactId':_0x14c0f1['id'],'closed':![],'OpenchannelAccountId':_0x14d9ae['id']}})[_0x06df('0x1d')](function(_0x2264e6){if(_0x2264e6){return[_0x2264e6,![]];}return db[_0x06df('0x8d')][_0x06df('0x56')]({'UserId':_0x164506['user']['id'],'ContactId':_0x14c0f1['id'],'OpenchannelAccountId':_0x14d9ae['id'],'lastMsgDirection':'out','firstMsgDirection':_0x06df('0xb9'),'Messages':[_[_0x06df('0x48')](_0x164506['body'],{'read':![],'body':_0x164506[_0x06df('0x60')]['body'],'OpenchannelAccountId':_0x14d9ae['id'],'UserId':_0x164506[_0x06df('0x57')]['id'],'ContactId':_0x14c0f1['id']})]},{'include':[{'model':db['OpenchannelMessage'],'as':'Messages'}]})[_0x06df('0x1d')](function(_0x2dc415){return[_0x2dc415,!![]];});});}})['spread'](function(_0x40072c,_0x446d84){if(_0x446d84){return _0x40072c;}return db[_0x06df('0xba')][_0x06df('0x56')](_[_0x06df('0x48')](_0x164506[_0x06df('0x60')],{'read':![],'body':_0x164506[_0x06df('0x60')][_0x06df('0x60')],'OpenchannelAccountId':_0x14d9ae['id'],'OpenchannelInteractionId':_0x40072c['id'],'UserId':_0x164506['user']['id'],'ContactId':_0x14c0f1['id']}))[_0x06df('0x1d')](function(_0x3e8fd7){_0x40072c[_0x06df('0xbb')][_0x06df('0xbc')]=[];_0x40072c[_0x06df('0xbb')]['Messages'][_0x06df('0x94')](_0x3e8fd7[_0x06df('0xbb')]);return _0x40072c;});});}})[_0x06df('0x1d')](respondWithResult(_0x17d156,null))[_0x06df('0x28')](handleError(_0x17d156,null));};
\ No newline at end of file
+var _0x05f1=['lastName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','contact','messageId','interaction','created','autoclose','push','unmanaged','UserId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','queueId','OpenchannelQueue','queue','waitForTheAssignedQueue','Start','EventManager','notify','sequelize','ISOLATION_LEVELS','READ_COMMITTED','OpenchannelApplication','bulkCreate','priority','finally','getApplications','getInteractions','Contact','fullname','internal','Tag','Tags','color','tag','addAgents','omit','emit','userOpenchannelAccount:save','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','out','Messages','OpenchannelMessage','dataValues','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','fs-extra','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','jayson/promise','client','http','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','update','destroy','UserProfileResource','sendStatus','stack','name','send','index','Pause','mandatoryDispositionPause','map','OpenchannelAccount','rawAttributes','fieldName','type','key','model','query','filters','attributes','intersection','fields','length','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','show','params','keys','include','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','OpenchannelAccounts','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','OpenchannelAccountId','Disposition','getDispositions','findOne','hasOwnProperty','findAll','removeDispositions','addAnswer','getAnswers','CannedAnswer','rows','removeAnswers','ids','Sequelize','ValidationError','no\x20available\x20attributes','difference','updatedAt','createdAt','CompanyId','ListId','from','isNil','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','CmContact','Contacts','DESC','account','applications','orderBy','asc','Applications','List','firstName'];(function(_0x3acb53,_0x57aefa){var _0x29167b=function(_0x43e31f){while(--_0x43e31f){_0x3acb53['push'](_0x3acb53['shift']());}};_0x29167b(++_0x57aefa);}(_0x05f1,0xfa));var _0x105f=function(_0x2c91e9,_0x2fb965){_0x2c91e9=_0x2c91e9-0x0;var _0x13f0ff=_0x05f1[_0x2c91e9];return _0x13f0ff;};'use strict';var emlformat=require(_0x105f('0x0'));var rimraf=require(_0x105f('0x1'));var zipdir=require(_0x105f('0x2'));var jsonpatch=require(_0x105f('0x3'));var rp=require(_0x105f('0x4'));var moment=require(_0x105f('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x105f('0x6'));var util=require(_0x105f('0x7'));var path=require(_0x105f('0x8'));var sox=require(_0x105f('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x105f('0xa'));var _=require(_0x105f('0xb'));var squel=require('squel');var crypto=require(_0x105f('0xc'));var jsforce=require(_0x105f('0xd'));var deskjs=require(_0x105f('0xe'));var toCsv=require('to-csv');var querystring=require(_0x105f('0xf'));var Papa=require('papaparse');var Redis=require(_0x105f('0x10'));var authService=require(_0x105f('0x11'));var qs=require(_0x105f('0x12'));var as=require(_0x105f('0x13'));var hardwareService=require(_0x105f('0x14'));var logger=require(_0x105f('0x15'))(_0x105f('0x16'));var utils=require(_0x105f('0x17'));var config=require(_0x105f('0x18'));var licenseUtil=require(_0x105f('0x19'));var db=require(_0x105f('0x1a'))['db'];config['redis']=_[_0x105f('0x1b')](config[_0x105f('0x1c')],{'host':'localhost','port':0x18eb});var socket=require(_0x105f('0x1d'))(new Redis(config[_0x105f('0x1c')]));require('./openchannelAccount.socket')['register'](socket);var jayson=require(_0x105f('0x1e'));var client=jayson[_0x105f('0x1f')][_0x105f('0x20')]({'port':0x232c});var client9002=jayson['client'][_0x105f('0x20')]({'port':0x232a});function respondWithRpcPromise(_0xafd716,_0x6f5937,_0x441df6,_0x296581){return new BPromise(function(_0x8c31a,_0x14fc84){var _0x31d577=_0x296581||client;return _0x31d577['request'](_0xafd716,_0x441df6)[_0x105f('0x21')](function(_0x175c14){logger[_0x105f('0x22')](_0x105f('0x23'),_0x6f5937,_0x105f('0x24'));logger[_0x105f('0x25')](_0x105f('0x26'),_0x6f5937,_0x105f('0x24'),JSON['stringify'](_0x175c14));if(_0x175c14[_0x105f('0x27')]){if(_0x175c14[_0x105f('0x27')][_0x105f('0x28')]===0x1f4){logger[_0x105f('0x27')]('OpenchannelAccount,\x20%s,\x20%s',_0x6f5937,_0x175c14[_0x105f('0x27')][_0x105f('0x29')]);return _0x14fc84(_0x175c14[_0x105f('0x27')][_0x105f('0x29')]);}logger['error'](_0x105f('0x23'),_0x6f5937,_0x175c14[_0x105f('0x27')][_0x105f('0x29')]);return _0x8c31a(_0x175c14[_0x105f('0x27')][_0x105f('0x29')]);}else{logger[_0x105f('0x22')](_0x105f('0x23'),_0x6f5937,'request\x20sent');_0x8c31a(_0x175c14[_0x105f('0x2a')][_0x105f('0x29')]);}})[_0x105f('0x2b')](function(_0x466034){logger[_0x105f('0x27')]('OpenchannelAccount,\x20%s,\x20%s',_0x6f5937,_0x466034);_0x14fc84(_0x466034);});});}function respondWithStatusCode(_0x2fd3a6,_0x438b32){_0x438b32=_0x438b32||0xcc;return function(_0x156abc){if(_0x156abc){return _0x2fd3a6['sendStatus'](_0x438b32);}return _0x2fd3a6[_0x105f('0x2c')](_0x438b32)[_0x105f('0x2d')]();};}function respondWithResult(_0x4e18b3,_0x52bf39){_0x52bf39=_0x52bf39||0xc8;return function(_0x311c86){if(_0x311c86){return _0x4e18b3[_0x105f('0x2c')](_0x52bf39)['json'](_0x311c86);}};}function respondWithFilteredResult(_0x439ae0,_0x45f7f8){return function(_0x5be288){if(_0x5be288){var _0x1acf1a=typeof _0x45f7f8[_0x105f('0x2e')]===_0x105f('0x2f')&&typeof _0x45f7f8[_0x105f('0x30')]==='undefined';var _0x5344b6=_0x5be288[_0x105f('0x31')];var _0x3a7215=_0x1acf1a?0x0:_0x45f7f8[_0x105f('0x2e')];var _0x291572=_0x1acf1a?_0x5be288[_0x105f('0x31')]:_0x45f7f8[_0x105f('0x2e')]+_0x45f7f8[_0x105f('0x30')];var _0xdcb3a1;if(_0x291572>=_0x5344b6){_0x291572=_0x5344b6;_0xdcb3a1=0xc8;}else{_0xdcb3a1=0xce;}_0x439ae0['status'](_0xdcb3a1);return _0x439ae0['set'](_0x105f('0x32'),_0x3a7215+'-'+_0x291572+'/'+_0x5344b6)[_0x105f('0x33')](_0x5be288);}return null;};}function patchUpdates(_0x1a31f5){return function(_0xc36080){try{jsonpatch[_0x105f('0x34')](_0xc36080,_0x1a31f5,!![]);}catch(_0x156cde){return BPromise[_0x105f('0x35')](_0x156cde);}return _0xc36080['save']();};}function saveUpdates(_0xf87cb0,_0xba9737){return function(_0x11f4dc){if(_0x11f4dc){return _0x11f4dc[_0x105f('0x36')](_0xf87cb0)[_0x105f('0x21')](function(_0x170bed){return _0x170bed;});}return null;};}function removeEntity(_0x361929,_0x5f40f8){return function(_0x24f9b6){if(_0x24f9b6){return _0x24f9b6[_0x105f('0x37')]()[_0x105f('0x21')](function(){var _0x1cc2bb=_0x24f9b6['get']({'plain':!![]});var _0x57c264='OpenchannelAccounts';return db[_0x105f('0x38')][_0x105f('0x37')]({'where':{'type':_0x57c264,'resourceId':_0x1cc2bb['id']}})['then'](function(){return _0x24f9b6;});})[_0x105f('0x21')](function(){_0x361929['status'](0xcc)[_0x105f('0x2d')]();});}};}function handleEntityNotFound(_0x2cd180,_0x576f6f){return function(_0x5d245f){if(!_0x5d245f){_0x2cd180[_0x105f('0x39')](0x194);}return _0x5d245f;};}function handleError(_0x1d9cd9,_0x59c9b5){_0x59c9b5=_0x59c9b5||0x1f4;return function(_0x10c98d){logger[_0x105f('0x27')](_0x10c98d[_0x105f('0x3a')]);if(_0x10c98d[_0x105f('0x3b')]){delete _0x10c98d[_0x105f('0x3b')];}_0x1d9cd9[_0x105f('0x2c')](_0x59c9b5)[_0x105f('0x3c')](_0x10c98d);};}exports[_0x105f('0x3d')]=function(_0x2e713e,_0x62ad32){var _0x28c7c9={'include':[{'model':db[_0x105f('0x3e')],'as':_0x105f('0x3f')}]},_0x31993b={},_0x3d43e6={'count':0x0,'rows':[]};var _0x37f562=_[_0x105f('0x40')](db[_0x105f('0x41')][_0x105f('0x42')],function(_0x43dcd2){return{'name':_0x43dcd2[_0x105f('0x43')],'type':_0x43dcd2[_0x105f('0x44')][_0x105f('0x45')]};});_0x31993b[_0x105f('0x46')]=_['map'](_0x37f562,_0x105f('0x3b'));_0x31993b['query']=_['keys'](_0x2e713e[_0x105f('0x47')]);_0x31993b[_0x105f('0x48')]=_['intersection'](_0x31993b[_0x105f('0x46')],_0x31993b['query']);_0x28c7c9[_0x105f('0x49')]=_[_0x105f('0x4a')](_0x31993b['model'],qs[_0x105f('0x4b')](_0x2e713e[_0x105f('0x47')][_0x105f('0x4b')]));_0x28c7c9['attributes']=_0x28c7c9[_0x105f('0x49')][_0x105f('0x4c')]?_0x28c7c9[_0x105f('0x49')]:_0x31993b[_0x105f('0x46')];if(!_0x2e713e[_0x105f('0x47')]['hasOwnProperty'](_0x105f('0x4d'))){_0x28c7c9[_0x105f('0x30')]=qs['limit'](_0x2e713e['query'][_0x105f('0x30')]);_0x28c7c9['offset']=qs[_0x105f('0x2e')](_0x2e713e[_0x105f('0x47')][_0x105f('0x2e')]);}_0x28c7c9[_0x105f('0x4e')]=qs[_0x105f('0x4f')](_0x2e713e[_0x105f('0x47')][_0x105f('0x4f')]);_0x28c7c9[_0x105f('0x50')]=qs[_0x105f('0x48')](_[_0x105f('0x51')](_0x2e713e['query'],_0x31993b[_0x105f('0x48')]),_0x37f562);if(_0x2e713e['query']['filter']){_0x28c7c9[_0x105f('0x50')]=_[_0x105f('0x52')](_0x28c7c9[_0x105f('0x50')],{'$or':_[_0x105f('0x40')](_0x37f562,function(_0x9ff489){if(_0x9ff489[_0x105f('0x44')]!==_0x105f('0x53')){var _0x1065e1={};_0x1065e1[_0x9ff489[_0x105f('0x3b')]]={'$like':'%'+_0x2e713e[_0x105f('0x47')][_0x105f('0x54')]+'%'};return _0x1065e1;}})});}_0x28c7c9=_[_0x105f('0x52')]({},_0x28c7c9,_0x2e713e[_0x105f('0x55')]);var _0x31c0a9={'where':_0x28c7c9['where']};return db[_0x105f('0x41')][_0x105f('0x31')](_0x31c0a9)[_0x105f('0x21')](function(_0x5236f9){_0x3d43e6[_0x105f('0x31')]=_0x5236f9;if(_0x2e713e[_0x105f('0x47')][_0x105f('0x56')]){_0x28c7c9['include']=[{'all':!![]}];}return db[_0x105f('0x41')]['findAll'](_0x28c7c9);})[_0x105f('0x21')](function(_0x5127b4){_0x3d43e6['rows']=_0x5127b4;return _0x3d43e6;})['then'](respondWithFilteredResult(_0x62ad32,_0x28c7c9))['catch'](handleError(_0x62ad32,null));};exports[_0x105f('0x57')]=function(_0x4512d5,_0x47c020){var _0x9166be={'raw':![],'where':{'id':_0x4512d5[_0x105f('0x58')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x92fcb9={};_0x92fcb9[_0x105f('0x46')]=_['keys'](db[_0x105f('0x41')]['rawAttributes']);_0x92fcb9[_0x105f('0x47')]=_[_0x105f('0x59')](_0x4512d5[_0x105f('0x47')]);_0x92fcb9[_0x105f('0x48')]=_[_0x105f('0x4a')](_0x92fcb9[_0x105f('0x46')],_0x92fcb9[_0x105f('0x47')]);_0x9166be[_0x105f('0x49')]=_[_0x105f('0x4a')](_0x92fcb9[_0x105f('0x46')],qs[_0x105f('0x4b')](_0x4512d5[_0x105f('0x47')][_0x105f('0x4b')]));_0x9166be[_0x105f('0x49')]=_0x9166be[_0x105f('0x49')][_0x105f('0x4c')]?_0x9166be[_0x105f('0x49')]:_0x92fcb9[_0x105f('0x46')];if(_0x4512d5[_0x105f('0x47')][_0x105f('0x56')]){_0x9166be[_0x105f('0x5a')]=[{'all':!![]}];}_0x9166be=_[_0x105f('0x52')]({},_0x9166be,_0x4512d5[_0x105f('0x55')]);return db[_0x105f('0x41')]['find'](_0x9166be)[_0x105f('0x21')](handleEntityNotFound(_0x47c020,null))[_0x105f('0x21')](respondWithResult(_0x47c020,null))[_0x105f('0x2b')](handleError(_0x47c020,null));};exports[_0x105f('0x5b')]=function(_0x3f72f5,_0x1155e8){return db[_0x105f('0x41')][_0x105f('0x5b')](_0x3f72f5[_0x105f('0x5c')],{})[_0x105f('0x21')](function(_0x5b062c){var _0x138a6a=_0x3f72f5['user'][_0x105f('0x5d')]({'plain':!![]});if(!_0x138a6a)throw new Error(_0x105f('0x5e'));if(_0x138a6a['role']===_0x105f('0x5f')){var _0x166a9e=_0x5b062c[_0x105f('0x5d')]({'plain':!![]});var _0x204671=_0x105f('0x60');return db[_0x105f('0x61')][_0x105f('0x62')]({'where':{'name':_0x204671,'userProfileId':_0x138a6a[_0x105f('0x63')]},'raw':!![]})[_0x105f('0x21')](function(_0x452579){if(_0x452579&&_0x452579[_0x105f('0x64')]===0x0){return db[_0x105f('0x38')]['create']({'name':_0x166a9e[_0x105f('0x3b')],'resourceId':_0x166a9e['id'],'type':_0x452579[_0x105f('0x3b')],'sectionId':_0x452579['id']},{})[_0x105f('0x21')](function(){return _0x5b062c;});}else{return _0x5b062c;}})[_0x105f('0x2b')](function(_0x4401f5){logger[_0x105f('0x27')](_0x105f('0x65'),_0x4401f5);throw _0x4401f5;});}return _0x5b062c;})[_0x105f('0x21')](respondWithResult(_0x1155e8,0xc9))['catch'](handleError(_0x1155e8,null));};exports[_0x105f('0x36')]=function(_0x43d1e8,_0x110d5d){if(_0x43d1e8['body']['id']){delete _0x43d1e8['body']['id'];}return db[_0x105f('0x41')][_0x105f('0x62')]({'where':{'id':_0x43d1e8[_0x105f('0x58')]['id']},'include':[{'model':db[_0x105f('0x3e')],'as':_0x105f('0x3f')}]})[_0x105f('0x21')](handleEntityNotFound(_0x110d5d,null))['then'](saveUpdates(_0x43d1e8[_0x105f('0x5c')],null))[_0x105f('0x21')](respondWithResult(_0x110d5d,null))[_0x105f('0x2b')](handleError(_0x110d5d,null));};exports[_0x105f('0x37')]=function(_0x477d54,_0x2a19ec){return db[_0x105f('0x41')][_0x105f('0x62')]({'where':{'id':_0x477d54[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x2a19ec,null))[_0x105f('0x21')](removeEntity(_0x2a19ec,null))[_0x105f('0x2b')](handleError(_0x2a19ec,null));};exports[_0x105f('0x66')]=function(_0x35e6d3,_0x1bd42a){return db[_0x105f('0x41')][_0x105f('0x66')]()[_0x105f('0x21')](respondWithResult(_0x1bd42a,null))['catch'](handleError(_0x1bd42a,null));};exports[_0x105f('0x67')]=function(_0x334421,_0x2baa2d,_0x1381e6){if(_0x334421[_0x105f('0x5c')]['id']){delete _0x334421[_0x105f('0x5c')]['id'];}return db[_0x105f('0x41')][_0x105f('0x62')]({'where':{'id':_0x334421[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x2baa2d,null))['then'](function(_0x4e602c){if(_0x4e602c){_0x334421['body'][_0x105f('0x68')]=_0x4e602c['id'];return db[_0x105f('0x69')]['create'](_0x334421['body']);}})[_0x105f('0x21')](respondWithResult(_0x2baa2d,null))[_0x105f('0x2b')](handleError(_0x2baa2d,null));};exports[_0x105f('0x6a')]=function(_0x2bd927,_0x5ac0e1,_0x529674){var _0x477d95={'raw':![],'where':{}};var _0x3ecd49={};var _0x15bbaa={'count':0x0,'rows':[]};return db[_0x105f('0x41')][_0x105f('0x6b')]({'where':{'id':_0x2bd927[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x5ac0e1,null))[_0x105f('0x21')](function(_0x5298eb){if(_0x5298eb){_0x3ecd49[_0x105f('0x46')]=_[_0x105f('0x59')](db[_0x105f('0x69')][_0x105f('0x42')]);_0x3ecd49[_0x105f('0x47')]=_[_0x105f('0x59')](_0x2bd927[_0x105f('0x47')]);_0x3ecd49['filters']=_[_0x105f('0x4a')](_0x3ecd49['model'],_0x3ecd49[_0x105f('0x47')]);_0x477d95[_0x105f('0x49')]=_[_0x105f('0x4a')](_0x3ecd49[_0x105f('0x46')],qs[_0x105f('0x4b')](_0x2bd927['query'][_0x105f('0x4b')]));_0x477d95[_0x105f('0x49')]=_0x477d95[_0x105f('0x49')]['length']?_0x477d95['attributes']:_0x3ecd49['model'];if(!_0x2bd927[_0x105f('0x47')][_0x105f('0x6c')]('nolimit')){_0x477d95[_0x105f('0x30')]=qs[_0x105f('0x30')](_0x2bd927[_0x105f('0x47')][_0x105f('0x30')]);_0x477d95[_0x105f('0x2e')]=qs[_0x105f('0x2e')](_0x2bd927[_0x105f('0x47')][_0x105f('0x2e')]);}_0x477d95[_0x105f('0x4e')]=qs[_0x105f('0x4f')](_0x2bd927['query']['sort']);_0x477d95['where']=qs[_0x105f('0x48')](_[_0x105f('0x51')](_0x2bd927[_0x105f('0x47')],_0x3ecd49['filters']));_0x477d95[_0x105f('0x50')][_0x105f('0x68')]=_0x5298eb['id'];if(_0x2bd927[_0x105f('0x47')][_0x105f('0x54')]){_0x477d95[_0x105f('0x50')]=_[_0x105f('0x52')](_0x477d95[_0x105f('0x50')],{'$or':_[_0x105f('0x40')](_0x477d95[_0x105f('0x49')],function(_0x401bba){var _0x228d66={};_0x228d66[_0x401bba]={'$like':'%'+_0x2bd927[_0x105f('0x47')][_0x105f('0x54')]+'%'};return _0x228d66;})});}_0x477d95=_[_0x105f('0x52')]({},_0x477d95,_0x2bd927['options']);return db[_0x105f('0x69')][_0x105f('0x31')]({'where':_0x477d95[_0x105f('0x50')]})[_0x105f('0x21')](function(_0x28f7e3){_0x15bbaa[_0x105f('0x31')]=_0x28f7e3;if(_0x2bd927['query'][_0x105f('0x56')]){_0x477d95[_0x105f('0x5a')]=[{'all':!![]}];}return db[_0x105f('0x69')][_0x105f('0x6d')](_0x477d95);})[_0x105f('0x21')](function(_0x53e366){_0x15bbaa['rows']=_0x53e366;return _0x15bbaa;});}})[_0x105f('0x21')](respondWithFilteredResult(_0x5ac0e1,_0x477d95))[_0x105f('0x2b')](handleError(_0x5ac0e1,null));};exports['removeDispositions']=function(_0x1aaf2c,_0x3caf01,_0x52b673){return db[_0x105f('0x41')]['find']({'where':{'id':_0x1aaf2c[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x3caf01,null))[_0x105f('0x21')](function(_0xab3de2){if(_0xab3de2){return _0xab3de2[_0x105f('0x6e')](_0x1aaf2c['query']['ids']);}})[_0x105f('0x21')](respondWithStatusCode(_0x3caf01,null))[_0x105f('0x2b')](handleError(_0x3caf01,null));};exports[_0x105f('0x6f')]=function(_0x196476,_0x1b96d3,_0x285dce){if(_0x196476['body']['id']){delete _0x196476[_0x105f('0x5c')]['id'];}return db[_0x105f('0x41')][_0x105f('0x62')]({'where':{'id':_0x196476[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x1b96d3,null))['then'](function(_0x8df2dc){if(_0x8df2dc){_0x196476[_0x105f('0x5c')][_0x105f('0x68')]=_0x8df2dc['id'];return db['CannedAnswer'][_0x105f('0x5b')](_0x196476[_0x105f('0x5c')]);}})[_0x105f('0x21')](respondWithResult(_0x1b96d3,null))[_0x105f('0x2b')](handleError(_0x1b96d3,null));};exports[_0x105f('0x70')]=function(_0x2517da,_0x5cee26,_0x3156e3){var _0x5604fc={'raw':![],'where':{}};var _0x119966={};var _0x4bd927={'count':0x0,'rows':[]};return db[_0x105f('0x41')]['findOne']({'where':{'id':_0x2517da[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x5cee26,null))[_0x105f('0x21')](function(_0x5280d9){if(_0x5280d9){_0x119966['model']=_[_0x105f('0x59')](db[_0x105f('0x71')]['rawAttributes']);_0x119966[_0x105f('0x47')]=_[_0x105f('0x59')](_0x2517da[_0x105f('0x47')]);_0x119966['filters']=_['intersection'](_0x119966['model'],_0x119966[_0x105f('0x47')]);_0x5604fc[_0x105f('0x49')]=_[_0x105f('0x4a')](_0x119966[_0x105f('0x46')],qs[_0x105f('0x4b')](_0x2517da[_0x105f('0x47')][_0x105f('0x4b')]));_0x5604fc[_0x105f('0x49')]=_0x5604fc[_0x105f('0x49')][_0x105f('0x4c')]?_0x5604fc[_0x105f('0x49')]:_0x119966[_0x105f('0x46')];if(!_0x2517da['query']['hasOwnProperty']('nolimit')){_0x5604fc[_0x105f('0x30')]=qs[_0x105f('0x30')](_0x2517da[_0x105f('0x47')]['limit']);_0x5604fc[_0x105f('0x2e')]=qs[_0x105f('0x2e')](_0x2517da[_0x105f('0x47')][_0x105f('0x2e')]);}_0x5604fc[_0x105f('0x4e')]=qs[_0x105f('0x4f')](_0x2517da[_0x105f('0x47')][_0x105f('0x4f')]);_0x5604fc[_0x105f('0x50')]=qs[_0x105f('0x48')](_[_0x105f('0x51')](_0x2517da[_0x105f('0x47')],_0x119966[_0x105f('0x48')]));_0x5604fc[_0x105f('0x50')][_0x105f('0x68')]=_0x5280d9['id'];if(_0x2517da['query'][_0x105f('0x54')]){_0x5604fc[_0x105f('0x50')]=_['merge'](_0x5604fc[_0x105f('0x50')],{'$or':_['map'](_0x5604fc[_0x105f('0x49')],function(_0x7859bb){var _0x2a182e={};_0x2a182e[_0x7859bb]={'$like':'%'+_0x2517da[_0x105f('0x47')][_0x105f('0x54')]+'%'};return _0x2a182e;})});}_0x5604fc=_[_0x105f('0x52')]({},_0x5604fc,_0x2517da[_0x105f('0x55')]);return db[_0x105f('0x71')]['count']({'where':_0x5604fc[_0x105f('0x50')]})[_0x105f('0x21')](function(_0x491d68){_0x4bd927[_0x105f('0x31')]=_0x491d68;if(_0x2517da[_0x105f('0x47')][_0x105f('0x56')]){_0x5604fc[_0x105f('0x5a')]=[{'all':!![]}];}return db[_0x105f('0x71')][_0x105f('0x6d')](_0x5604fc);})[_0x105f('0x21')](function(_0x27f66a){_0x4bd927[_0x105f('0x72')]=_0x27f66a;return _0x4bd927;});}})[_0x105f('0x21')](respondWithFilteredResult(_0x5cee26,_0x5604fc))[_0x105f('0x2b')](handleError(_0x5cee26,null));};exports[_0x105f('0x73')]=function(_0x482637,_0x358272,_0x4943bc){return db['OpenchannelAccount'][_0x105f('0x62')]({'where':{'id':_0x482637[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x358272,null))[_0x105f('0x21')](function(_0x553b06){if(_0x553b06){return _0x553b06[_0x105f('0x73')](_0x482637[_0x105f('0x47')][_0x105f('0x74')]);}})[_0x105f('0x21')](respondWithStatusCode(_0x358272,null))[_0x105f('0x2b')](handleError(_0x358272,null));};exports['notify']=function(_0x4ad7c6,_0x32cc6e,_0x4fda6b){var _0x4ea2f2={'body':_0x4ad7c6[_0x105f('0x5c')],'channel':'openchannel'};var _0x3facd5=[];var _0x30054a=[];var _0x1bf4c8={};var _0x493f0c=![];return db['CmContact'][_0x105f('0x66')]()['then'](function(_0x2f7970){if(!_0x2f7970){throw new db[(_0x105f('0x75'))][(_0x105f('0x76'))](_0x105f('0x77'));}_0x3facd5=_[_0x105f('0x78')](_[_0x105f('0x59')](_0x2f7970),['createdAt',_0x105f('0x79')]);_0x30054a=_[_0x105f('0x78')](_[_0x105f('0x59')](_0x2f7970),[_0x105f('0x7a'),_0x105f('0x79'),_0x105f('0x7b'),_0x105f('0x7c')]);if(_0x4ad7c6['body']['id']){delete _0x4ad7c6['body']['id'];}if(_['isNil'](_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x7d')])){throw new db[(_0x105f('0x75'))]['ValidationError']('from\x20is\x20mandatory');}if(_[_0x105f('0x7e')](_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x5c')])||_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x5c')]===''){throw new db[(_0x105f('0x75'))][(_0x105f('0x76'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x105f('0x7e')](_0x4ad7c6[_0x105f('0x5c')]['mapKey'])){throw new db[(_0x105f('0x75'))][(_0x105f('0x76'))](_0x105f('0x7f')+_0x30054a);}if(!_[_0x105f('0x80')](_0x30054a,_0x4ad7c6['body'][_0x105f('0x81')])){throw new db[(_0x105f('0x75'))]['ValidationError'](_0x105f('0x82')+_0x30054a);}_0x1bf4c8[_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x81')]]=_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x7d')];})[_0x105f('0x21')](function(){return db[_0x105f('0x41')][_0x105f('0x62')]({'where':{'id':_0x4ad7c6[_0x105f('0x58')]['id']},'include':[{'model':db[_0x105f('0x83')],'as':'List','include':[{'model':db[_0x105f('0x84')],'as':_0x105f('0x85'),'where':_0x1bf4c8,'limit':0x1,'order':[[_0x105f('0x79'),_0x105f('0x86')]]}]},{'model':db['OpenchannelApplication'],'as':'Applications'}]});})[_0x105f('0x21')](handleEntityNotFound(_0x32cc6e,null))[_0x105f('0x21')](function(_0x309eec){if(_0x309eec&&_0x309eec['List']){_0x4ea2f2[_0x105f('0x87')]=_0x309eec;_0x4ea2f2[_0x105f('0x88')]=_0x309eec['Applications'];_0x4ea2f2['list']=_0x309eec['List'];_0x4ea2f2[_0x105f('0x88')]=_[_0x105f('0x89')](_0x4ea2f2['applications'],['priority'],[_0x105f('0x8a')]);if(_0x4ea2f2['account'][_0x105f('0x8b')]){delete _0x4ea2f2['account'][_0x105f('0x8b')];}if(_0x4ea2f2[_0x105f('0x87')][_0x105f('0x8c')]&&_0x4ea2f2[_0x105f('0x87')][_0x105f('0x8c')][_0x105f('0x85')][_0x105f('0x4c')]){return _0x4ea2f2[_0x105f('0x87')][_0x105f('0x8c')]['Contacts'][0x0];}var _0x331a19=_[_0x105f('0x1b')](_0x4ad7c6['body'],{'firstName':_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x7d')],'ListId':_0x309eec[_0x105f('0x7c')]});_0x331a19[_0x4ad7c6['body'][_0x105f('0x81')]]=_0x4ad7c6[_0x105f('0x5c')]['from'];return db[_0x105f('0x84')][_0x105f('0x5b')](_0x331a19,{'fields':_0x3facd5,'raw':!![]});}})[_0x105f('0x21')](handleEntityNotFound(_0x32cc6e,null))[_0x105f('0x21')](function(_0x1e63d8){_0x4ea2f2['contact']=_0x1e63d8;if(_0x1e63d8){var _0x5652a6={'ContactId':_0x1e63d8['id'],'OpenchannelAccountId':_0x4ad7c6['params']['id'],'from':(_0x1e63d8[_0x105f('0x8d')]||'')+'\x20'+(_0x1e63d8[_0x105f('0x8e')]||'')};var _0x350b19={'OpenchannelAccountId':_0x4ad7c6[_0x105f('0x58')]['id'],'closed':![]};if(_0x4ad7c6[_0x105f('0x5c')]['threadId']){_0x350b19[_0x105f('0x8f')]=_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x8f')];return db[_0x105f('0x90')]['find']({'where':_0x350b19})[_0x105f('0x21')](function(_0x39245d){if(_0x39245d){return[_0x39245d,![]];}_0x5652a6[_0x105f('0x8f')]=_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x8f')];_0x5652a6['externalUrl']=_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x91')];return db[_0x105f('0x90')]['create'](_0x5652a6)[_0x105f('0x21')](function(_0x3b3eb4){return[_0x3b3eb4,!![]];});});}else{_0x350b19['threadId']=null;}_0x350b19[_0x105f('0x92')]=_0x1e63d8['id'];return db[_0x105f('0x90')][_0x105f('0x62')]({'where':_0x350b19})[_0x105f('0x21')](function(_0x1cde1c){if(_0x1cde1c){return[_0x1cde1c,![]];}return db[_0x105f('0x90')][_0x105f('0x5b')](_0x5652a6)[_0x105f('0x21')](function(_0x2ff1be){return[_0x2ff1be,!![]];});});}})[_0x105f('0x93')](function(_0x9fb597,_0x12c4fd){if(_0x9fb597){_0x493f0c=_0x12c4fd;if(!_0x12c4fd){var _0x4c64e6={'from':(_0x4ea2f2[_0x105f('0x94')][_0x105f('0x8d')]||'')+'\x20'+(_0x4ea2f2['contact'][_0x105f('0x8e')]||'')};if(_0x4ad7c6['body']['threadId']&&_0x4ad7c6['body'][_0x105f('0x95')]&&_0x4ad7c6['body'][_0x105f('0x8f')]!=_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x95')]){_0x4c64e6[_0x105f('0x8f')]=_0x4ad7c6[_0x105f('0x5c')]['messageId'];}return _0x9fb597[_0x105f('0x36')](_0x4c64e6);}else{return _0x9fb597;}}})[_0x105f('0x21')](function(_0x4b3b64){_0x4ea2f2[_0x105f('0x96')]=_0x4b3b64[_0x105f('0x5d')]({'plain':!![]});_0x4ea2f2['interaction'][_0x105f('0x97')]=_0x493f0c;if(_0x4ea2f2[_0x105f('0x96')][_0x105f('0x97')]){if(_0x4ea2f2[_0x105f('0x87')][_0x105f('0x98')]){_0x4ea2f2[_0x105f('0x88')][_0x105f('0x99')]({'id':0x0,'priority':_0x4ea2f2[_0x105f('0x88')][_0x105f('0x4c')]+0x1,'app':'close','appdata':_0x105f('0x9a'),'interval':'*,*,*,*'});}}return db['OpenchannelMessage']['create']({'body':_0x4ad7c6[_0x105f('0x5c')][_0x105f('0x5c')],'OpenchannelAccountId':_0x4ad7c6[_0x105f('0x58')]['id'],'OpenchannelInteractionId':_0x4b3b64['id'],'direction':'in','ContactId':_0x4ea2f2[_0x105f('0x94')]['id'],'AttachmentId':_0x4ad7c6[_0x105f('0x5c')]['AttachmentId']});})['then'](function(_0x52d3a2){_0x4ea2f2[_0x105f('0x29')]=_0x52d3a2;if(!_0x4ea2f2['interaction'][_0x105f('0x9b')])return;return db[_0x105f('0x9c')][_0x105f('0x62')]({'attributes':['id',_0x105f('0x3b')],'where':{'id':_0x4ea2f2[_0x105f('0x96')][_0x105f('0x9b')]}});})[_0x105f('0x21')](function(_0x4f25b1){if(_0x4f25b1){_0x4ea2f2['applications'][_0x105f('0x9d')]({'id':0x0,'priority':0x0,'app':_0x105f('0x9e'),'appdata':_0x4f25b1[_0x105f('0x3b')]+','+(_0x4ea2f2['account'][_0x105f('0x9f')]||0xa),'interval':_0x105f('0xa0')});}if(!_0x4ea2f2[_0x105f('0x96')][_0x105f('0xa1')])return;return db[_0x105f('0xa2')][_0x105f('0x62')]({'attributes':['id',_0x105f('0x3b')],'where':{'id':_0x4ea2f2['interaction'][_0x105f('0xa1')]}});})[_0x105f('0x21')](function(_0x3256f2){if(_0x3256f2){_0x4ea2f2[_0x105f('0x88')]['unshift']({'id':0x0,'priority':0x1,'app':_0x105f('0xa3'),'appdata':_0x3256f2[_0x105f('0x3b')]+','+(_0x4ea2f2[_0x105f('0x87')][_0x105f('0xa4')]||0x12c),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0x105f('0xa5'),'startRouting',_0x4ea2f2);})[_0x105f('0x21')](function(_0x3a9905){respondWithRpcPromise(_0x105f('0xa6'),_0x105f('0xa6'),{'event':_0x105f('0xa7'),'message':_0x3a9905},client9002);return _0x3a9905;})[_0x105f('0x21')](respondWithResult(_0x32cc6e,null))[_0x105f('0x2b')](handleError(_0x32cc6e,null));};exports['addApplications']=function(_0x484c51,_0x3a860c){var _0x3bcd31=_0x484c51[_0x105f('0x58')]['id'];var _0x5b85f8=_0x484c51['body'];var _0x887156=0xc8;var _0x462b51=null;return db[_0x105f('0xa8')]['transaction']({'isolationLevel':db[_0x105f('0xa8')]['Transaction'][_0x105f('0xa9')][_0x105f('0xaa')]},function(_0x45d7cf){return db['OpenchannelAccount']['findOne']({'where':{'id':_0x3bcd31},'transaction':_0x45d7cf})[_0x105f('0x21')](function(_0x44acc4){if(_0x44acc4){return db[_0x105f('0xab')][_0x105f('0x37')]({'where':{'OpenchannelAccountId':_0x3bcd31},'transaction':_0x45d7cf})['then'](function(){var _0xe05dcf=_[_0x105f('0x40')](_0x5b85f8,function(_0x5ad117){_0x5ad117[_0x105f('0x68')]=_0x3bcd31;return _0x5ad117;});return db[_0x105f('0xab')][_0x105f('0xac')](_0xe05dcf,{'transaction':_0x45d7cf});});}else{_0x887156=0x194;_0x462b51=[];}});})['then'](function(){if(_0x887156!==0x194){return db[_0x105f('0xab')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0x3bcd31},'order':_0x105f('0xad')})[_0x105f('0x21')](function(_0x2cb71f){_0x462b51=_0x2cb71f;});}})[_0x105f('0x2b')](function(_0x17dfb3){_0x887156=0x1f4;logger[_0x105f('0x27')](_0x17dfb3[_0x105f('0x3a')]);if(_0x17dfb3[_0x105f('0x3b')]){delete _0x17dfb3[_0x105f('0x3b')];}_0x462b51=_0x17dfb3;})[_0x105f('0xae')](function(){if(_0x462b51===null){_0x3a860c['sendStatus'](_0x887156);}else{if(_0x887156===0x1f4){_0x3a860c['status'](_0x887156)[_0x105f('0x3c')](_0x462b51);}else{_0x3a860c[_0x105f('0x2c')](_0x887156)[_0x105f('0x33')](_0x462b51);}}});};exports['getApplications']=function(_0x3a37e8,_0x1edec2,_0x558e66){var _0x310b50={};var _0x56490a={};var _0x5dbf9c;var _0x4bf6d7;return db[_0x105f('0x41')][_0x105f('0x6b')]({'where':{'id':_0x3a37e8[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x1edec2,null))['then'](function(_0x4b6feb){if(_0x4b6feb){_0x5dbf9c=_0x4b6feb;_0x56490a[_0x105f('0x46')]=_['keys'](db[_0x105f('0xab')][_0x105f('0x42')]);_0x56490a[_0x105f('0x47')]=_[_0x105f('0x59')](_0x3a37e8[_0x105f('0x47')]);_0x56490a[_0x105f('0x48')]=_['intersection'](_0x56490a[_0x105f('0x46')],_0x56490a['query']);_0x310b50[_0x105f('0x49')]=_[_0x105f('0x4a')](_0x56490a[_0x105f('0x46')],qs[_0x105f('0x4b')](_0x3a37e8['query'][_0x105f('0x4b')]));_0x310b50[_0x105f('0x49')]=_0x310b50['attributes'][_0x105f('0x4c')]?_0x310b50[_0x105f('0x49')]:_0x56490a[_0x105f('0x46')];_0x310b50[_0x105f('0x4e')]=qs['sort'](_0x3a37e8[_0x105f('0x47')][_0x105f('0x4f')]);_0x310b50[_0x105f('0x50')]=qs[_0x105f('0x48')](_[_0x105f('0x51')](_0x3a37e8['query'],_0x56490a['filters']));if(_0x3a37e8['query'][_0x105f('0x54')]){_0x310b50['where']=_[_0x105f('0x52')](_0x310b50['where'],{'$or':_['map'](_0x310b50[_0x105f('0x49')],function(_0x276a54){var _0x1c7040={};_0x1c7040[_0x276a54]={'$like':'%'+_0x3a37e8['query'][_0x105f('0x54')]+'%'};return _0x1c7040;})});}_0x310b50=_[_0x105f('0x52')]({},_0x310b50,_0x3a37e8[_0x105f('0x55')]);return _0x5dbf9c[_0x105f('0xaf')](_0x310b50);}})['then'](function(_0x6f6048){if(_0x6f6048){_0x4bf6d7=_0x6f6048[_0x105f('0x4c')];if(!_0x3a37e8[_0x105f('0x47')][_0x105f('0x6c')]('nolimit')){_0x310b50[_0x105f('0x30')]=qs[_0x105f('0x30')](_0x3a37e8['query'][_0x105f('0x30')]);_0x310b50[_0x105f('0x2e')]=qs[_0x105f('0x2e')](_0x3a37e8['query'][_0x105f('0x2e')]);}return _0x5dbf9c[_0x105f('0xaf')](_0x310b50);}})[_0x105f('0x21')](function(_0x5409af){if(_0x5409af){return _0x5409af?{'count':_0x4bf6d7,'rows':_0x5409af}:null;}})[_0x105f('0x21')](respondWithResult(_0x1edec2,null))['catch'](handleError(_0x1edec2,null));};exports[_0x105f('0xb0')]=function(_0x38baa1,_0x367bd4,_0x32c39e){var _0x51fb6a={'raw':![],'where':{}};var _0x3741e1={};var _0x439885={'count':0x0,'rows':[]};return db[_0x105f('0x41')][_0x105f('0x6b')]({'where':{'id':_0x38baa1[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x367bd4,null))[_0x105f('0x21')](function(_0x35a3e1){if(_0x35a3e1){_0x3741e1[_0x105f('0x46')]=_[_0x105f('0x59')](db[_0x105f('0x90')]['rawAttributes']);_0x3741e1[_0x105f('0x47')]=_[_0x105f('0x59')](_0x38baa1[_0x105f('0x47')]);_0x3741e1[_0x105f('0x48')]=_['intersection'](_0x3741e1[_0x105f('0x46')],_0x3741e1['query']);_0x51fb6a['attributes']=_[_0x105f('0x4a')](_0x3741e1[_0x105f('0x46')],qs['fields'](_0x38baa1[_0x105f('0x47')][_0x105f('0x4b')]));_0x51fb6a[_0x105f('0x49')]=_0x51fb6a['attributes'][_0x105f('0x4c')]?_0x51fb6a[_0x105f('0x49')]:_0x3741e1['model'];if(!_0x38baa1[_0x105f('0x47')][_0x105f('0x6c')](_0x105f('0x4d'))){_0x51fb6a[_0x105f('0x30')]=qs[_0x105f('0x30')](_0x38baa1[_0x105f('0x47')][_0x105f('0x30')]);_0x51fb6a[_0x105f('0x2e')]=qs[_0x105f('0x2e')](_0x38baa1[_0x105f('0x47')][_0x105f('0x2e')]);}_0x51fb6a[_0x105f('0x4e')]=qs[_0x105f('0x4f')](_0x38baa1[_0x105f('0x47')]['sort']);_0x51fb6a[_0x105f('0x50')]=qs[_0x105f('0x48')](_[_0x105f('0x51')](_0x38baa1[_0x105f('0x47')],_0x3741e1['filters']));_0x51fb6a['where'][_0x105f('0x68')]=_0x35a3e1['id'];if(_0x38baa1[_0x105f('0x47')][_0x105f('0x54')]){_0x51fb6a[_0x105f('0x50')]=_[_0x105f('0x52')](_0x51fb6a[_0x105f('0x50')],{'$or':_[_0x105f('0x40')](_0x51fb6a['attributes'],function(_0x269f5d){var _0x230b51={};_0x230b51[_0x269f5d]={'$like':'%'+_0x38baa1[_0x105f('0x47')][_0x105f('0x54')]+'%'};return _0x230b51;})});}_0x51fb6a=_['merge']({},_0x51fb6a,_0x38baa1[_0x105f('0x55')]);return db[_0x105f('0x90')][_0x105f('0x31')]({'where':_0x51fb6a[_0x105f('0x50')]})['then'](function(_0x279a5b){_0x439885['count']=_0x279a5b;if(_0x38baa1[_0x105f('0x47')][_0x105f('0x56')]){_0x51fb6a[_0x105f('0x5a')]=[{'model':db[_0x105f('0x84')],'as':_0x105f('0xb1'),'required':![]},{'model':db['User'],'as':'Owner','attributes':[_0x105f('0x3b'),_0x105f('0xb2'),_0x105f('0xb3')],'required':![]},{'model':db[_0x105f('0xb4')],'as':_0x105f('0xb5'),'attributes':['id',_0x105f('0x3b'),_0x105f('0xb6')],'where':_0x38baa1[_0x105f('0x47')][_0x105f('0xb7')]?{'id':_0x38baa1[_0x105f('0x47')][_0x105f('0xb7')]}:undefined,'required':_0x38baa1[_0x105f('0x47')][_0x105f('0xb7')]?!![]:![]}];}return db[_0x105f('0x90')][_0x105f('0x6d')](_0x51fb6a);})[_0x105f('0x21')](function(_0x196de4){_0x439885['rows']=_0x196de4;return _0x439885;});}})['then'](respondWithFilteredResult(_0x367bd4,_0x51fb6a))['catch'](handleError(_0x367bd4,null));};exports[_0x105f('0xb8')]=function(_0x581916,_0x465c5e,_0x18fce2){return db[_0x105f('0x41')][_0x105f('0x62')]({'where':{'id':_0x581916[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x465c5e,null))['then'](function(_0x4a4b86){if(_0x4a4b86){return _0x4a4b86[_0x105f('0xb8')](_0x581916[_0x105f('0x5c')][_0x105f('0x74')],_[_0x105f('0xb9')](_0x581916[_0x105f('0x5c')],[_0x105f('0x74'),'id'])||{})[_0x105f('0x93')](function(_0x4ecd66){for(var _0x132d71=0x0;_0x132d71<_0x581916[_0x105f('0x5c')][_0x105f('0x74')][_0x105f('0x4c')];_0x132d71+=0x1){socket[_0x105f('0xba')](_0x105f('0xbb'),{'UserId':Number(_0x581916[_0x105f('0x5c')]['ids'][_0x132d71]),'OpenchannelAccountId':Number(_0x581916['params']['id'])});}return _0x4ecd66;});}})['then'](respondWithResult(_0x465c5e,null))[_0x105f('0x2b')](handleError(_0x465c5e,null));};exports[_0x105f('0xbc')]=function(_0x157248,_0x3f1f5c,_0xec717a){return db[_0x105f('0x41')][_0x105f('0x62')]({'where':{'id':_0x157248[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x3f1f5c,null))[_0x105f('0x21')](function(_0x380248){if(_0x380248){return _0x380248[_0x105f('0xbc')](_0x157248[_0x105f('0x47')]['ids'])['then'](function(){if(_[_0x105f('0xbd')](_0x157248[_0x105f('0x47')][_0x105f('0x74')])){for(var _0x547867=0x0;_0x547867<_0x157248[_0x105f('0x47')][_0x105f('0x74')][_0x105f('0x4c')];_0x547867+=0x1){socket[_0x105f('0xba')](_0x105f('0xbe'),{'UserId':Number(_0x157248[_0x105f('0x47')][_0x105f('0x74')][_0x547867]),'OpenchannelAccountId':Number(_0x157248[_0x105f('0x58')]['id'])});}}else{socket[_0x105f('0xba')]('userOpenchannelAccount:remove',{'UserId':Number(_0x157248[_0x105f('0x47')][_0x105f('0x74')]),'OpenchannelAccountId':Number(_0x157248[_0x105f('0x58')]['id'])});}});}})[_0x105f('0x21')](respondWithStatusCode(_0x3f1f5c,null))[_0x105f('0x2b')](handleError(_0x3f1f5c,null));};exports[_0x105f('0xbf')]=function(_0x26174c,_0x354242,_0x1f4213){var _0x5c3497={};var _0xf14d7b={};var _0x439db1;var _0x137cf3;return db['OpenchannelAccount'][_0x105f('0x6b')]({'where':{'id':_0x26174c[_0x105f('0x58')]['id']}})[_0x105f('0x21')](handleEntityNotFound(_0x354242,null))[_0x105f('0x21')](function(_0x244b9a){if(_0x244b9a){_0x439db1=_0x244b9a;_0xf14d7b[_0x105f('0x46')]=_[_0x105f('0x59')](db['User'][_0x105f('0x42')]);_0xf14d7b[_0x105f('0x47')]=_[_0x105f('0x59')](_0x26174c['query']);_0xf14d7b[_0x105f('0x48')]=_['intersection'](_0xf14d7b[_0x105f('0x46')],_0xf14d7b[_0x105f('0x47')]);_0x5c3497[_0x105f('0x49')]=_[_0x105f('0x4a')](_0xf14d7b[_0x105f('0x46')],qs[_0x105f('0x4b')](_0x26174c[_0x105f('0x47')][_0x105f('0x4b')]));_0x5c3497['attributes']=_0x5c3497[_0x105f('0x49')]['length']?_0x5c3497[_0x105f('0x49')]:_0xf14d7b[_0x105f('0x46')];_0x5c3497[_0x105f('0x4e')]=qs[_0x105f('0x4f')](_0x26174c[_0x105f('0x47')][_0x105f('0x4f')]);_0x5c3497[_0x105f('0x50')]=qs[_0x105f('0x48')](_['pick'](_0x26174c['query'],_0xf14d7b[_0x105f('0x48')]));if(_0x26174c[_0x105f('0x47')]['filter']){_0x5c3497[_0x105f('0x50')]=_['merge'](_0x5c3497[_0x105f('0x50')],{'$or':_['map'](_0x5c3497[_0x105f('0x49')],function(_0x54a703){var _0x33f6be={};_0x33f6be[_0x54a703]={'$like':'%'+_0x26174c['query'][_0x105f('0x54')]+'%'};return _0x33f6be;})});}_0x5c3497=_['merge']({},_0x5c3497,_0x26174c[_0x105f('0x55')]);return _0x439db1[_0x105f('0xbf')](_0x5c3497);}})[_0x105f('0x21')](function(_0x1020cc){if(_0x1020cc){_0x137cf3=_0x1020cc['length'];if(!_0x26174c['query'][_0x105f('0x6c')](_0x105f('0x4d'))){_0x5c3497[_0x105f('0x30')]=qs['limit'](_0x26174c[_0x105f('0x47')][_0x105f('0x30')]);_0x5c3497['offset']=qs['offset'](_0x26174c[_0x105f('0x47')][_0x105f('0x2e')]);}return _0x439db1[_0x105f('0xbf')](_0x5c3497);}})[_0x105f('0x21')](function(_0x18afb0){if(_0x18afb0){return _0x18afb0?{'count':_0x137cf3,'rows':_0x18afb0}:null;}})[_0x105f('0x21')](respondWithResult(_0x354242,null))[_0x105f('0x2b')](handleError(_0x354242,null));};exports[_0x105f('0x3c')]=function(_0x16e028,_0x562233,_0x5f2abe){var _0x5a5f14,_0x4fa02e,_0x46d82e;if(_[_0x105f('0x7e')](_0x16e028[_0x105f('0x5c')][_0x105f('0x5c')])||_0x16e028[_0x105f('0x5c')]['body']===''){throw new db[(_0x105f('0x75'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x105f('0x7e')](_0x16e028['body']['to'])){}_0x5a5f14=_0x16e028[_0x105f('0x5c')]['to'];return db[_0x105f('0x41')][_0x105f('0x6b')]({'where':{'id':_0x16e028[_0x105f('0x58')]['id']}})['then'](handleEntityNotFound(_0x562233,null))['then'](function(_0x2eebfc){if(_0x2eebfc){return db['OpenchannelAccount'][_0x105f('0x62')]({'where':{'id':_0x2eebfc['id']},'include':[{'model':db[_0x105f('0x83')],'as':'List','include':[{'model':db['CmContact'],'as':'Contacts','where':{[_0x2eebfc[_0x105f('0x81')]]:_0x5a5f14},'limit':0x1,'order':[[_0x105f('0x79'),_0x105f('0x86')]]}]}]})[_0x105f('0x21')](handleEntityNotFound(_0x562233,null))['then'](function(_0x309ba2){if(_0x309ba2&&_0x309ba2[_0x105f('0x8c')]){_0x4fa02e=_0x309ba2[_0x105f('0x5d')]({'plain':!![]});if(_0x4fa02e[_0x105f('0x8c')]&&_0x4fa02e[_0x105f('0x8c')][_0x105f('0x85')]['length']){return _0x4fa02e['List']['Contacts'][0x0];}return db[_0x105f('0x84')][_0x105f('0x5b')](_[_0x105f('0x1b')](_0x16e028[_0x105f('0x5c')],{'firstName':_0x5a5f14,[_0x309ba2[_0x105f('0x81')]]:_0x5a5f14,'phone':_0x5a5f14,'ListId':_0x4fa02e[_0x105f('0x7c')]}));}})[_0x105f('0x21')](handleEntityNotFound(_0x562233,null))[_0x105f('0x21')](function(_0x3da81c){if(_0x3da81c){_0x46d82e=_0x3da81c;return db[_0x105f('0x90')][_0x105f('0x62')]({'where':{'ContactId':_0x46d82e['id'],'closed':![],'OpenchannelAccountId':_0x4fa02e['id']}})[_0x105f('0x21')](function(_0x4a6c44){if(_0x4a6c44){return[_0x4a6c44,![]];}return db[_0x105f('0x90')][_0x105f('0x5b')]({'UserId':_0x16e028[_0x105f('0x5f')]['id'],'ContactId':_0x46d82e['id'],'OpenchannelAccountId':_0x4fa02e['id'],'lastMsgDirection':_0x105f('0xc0'),'firstMsgDirection':_0x105f('0xc0'),'Messages':[_[_0x105f('0x52')](_0x16e028[_0x105f('0x5c')],{'read':![],'body':_0x16e028[_0x105f('0x5c')][_0x105f('0x5c')],'OpenchannelAccountId':_0x4fa02e['id'],'UserId':_0x16e028[_0x105f('0x5f')]['id'],'ContactId':_0x46d82e['id']})]},{'include':[{'model':db['OpenchannelMessage'],'as':_0x105f('0xc1')}]})[_0x105f('0x21')](function(_0x4dfdfb){return[_0x4dfdfb,!![]];});});}})[_0x105f('0x93')](function(_0x37096b,_0x1bb157){if(_0x1bb157){return _0x37096b;}return db[_0x105f('0xc2')][_0x105f('0x5b')](_[_0x105f('0x52')](_0x16e028[_0x105f('0x5c')],{'read':![],'body':_0x16e028[_0x105f('0x5c')]['body'],'OpenchannelAccountId':_0x4fa02e['id'],'OpenchannelInteractionId':_0x37096b['id'],'UserId':_0x16e028['user']['id'],'ContactId':_0x46d82e['id']}))[_0x105f('0x21')](function(_0x106fd8){_0x37096b[_0x105f('0xc3')][_0x105f('0xc1')]=[];_0x37096b[_0x105f('0xc3')]['Messages'][_0x105f('0x99')](_0x106fd8[_0x105f('0xc3')]);return _0x37096b;});});}})['then'](respondWithResult(_0x562233,null))['catch'](handleError(_0x562233,null));};
\ No newline at end of file