Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index b086918..eb94701 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5c36=['papaparse','../../components/auth/service','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelAccount.socket','register','jayson/promise','client','http','test','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','error','code','message','catch','sendStatus','status','end','count','offset','set','json','apply','save','destroy','get','OpenchannelAccounts','UserProfileResource','stack','name','mandatoryDispositionPause','map','OpenchannelAccount','rawAttributes','fieldName','type','query','keys','filters','intersection','attributes','model','fields','length','nolimit','limit','sort','where','pick','merge','filter','options','includeAll','include','findAll','show','params','Pause','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','OpnechannelAccountId','getDispositions','Disposition','hasOwnProperty','OpenchannelAccountId','rows','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','findOne','removeAnswers','openchannel','CmContact','Sequelize','difference','createdAt','updatedAt','CompanyId','isNil','from','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','OpenchannelApplication','account','applications','Applications','list','orderBy','priority','asc','ListId','firstName','lastName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','contact','messageId','interaction','created','autoclose','push','*,*,*,*','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','notify','addApplications','sequelize','transaction','bulkCreate','findAndCountAll','getApplications','order','getInteractions','fullname','color','tag','addAgents','emit','userOpenchannelAccount:save','removeAgents','userOpenchannelAccount:remove','getAgents','body\x20is\x20mandatory\x20and\x20not\x20empty','DESC','out','OpenchannelMessage','Messages','dataValues','html-pdf','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js'];(function(_0x4da5e8,_0x55635b){var _0x386d21=function(_0x52296b){while(--_0x52296b){_0x4da5e8['push'](_0x4da5e8['shift']());}};_0x386d21(++_0x55635b);}(_0x5c36,0xa9));var _0x65c3=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0x5c36[_0x2641f9];return _0x585741;};'use strict';var pdf=require(_0x65c3('0x0'));var emlformat=require(_0x65c3('0x1'));var rimraf=require(_0x65c3('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x65c3('0x3'));var rp=require('request-promise');var moment=require(_0x65c3('0x4'));var BPromise=require(_0x65c3('0x5'));var Mustache=require(_0x65c3('0x6'));var util=require(_0x65c3('0x7'));var path=require(_0x65c3('0x8'));var sox=require(_0x65c3('0x9'));var csv=require(_0x65c3('0xa'));var ejs=require(_0x65c3('0xb'));var fs=require('fs');var _=require(_0x65c3('0xc'));var squel=require(_0x65c3('0xd'));var crypto=require('crypto');var jsforce=require(_0x65c3('0xe'));var deskjs=require(_0x65c3('0xf'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x65c3('0x10'));var Redis=require('ioredis');var authService=require(_0x65c3('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x65c3('0x12'));var utils=require(_0x65c3('0x13'));var config=require(_0x65c3('0x14'));var db=require(_0x65c3('0x15'))['db'];config[_0x65c3('0x16')]=_[_0x65c3('0x17')](config[_0x65c3('0x16')],{'host':_0x65c3('0x18'),'port':0x18eb});var socket=require(_0x65c3('0x19'))(new Redis(config['redis']));require(_0x65c3('0x1a'))[_0x65c3('0x1b')](socket);var jayson=require(_0x65c3('0x1c'));var client=jayson[_0x65c3('0x1d')][_0x65c3('0x1e')]({'port':0x232c});var client9002=jayson[_0x65c3('0x1d')][_0x65c3('0x1e')]({'port':0x232a});function checkPasswordPattern(_0x3d691e,_0x25ce94,_0x4987d5){if(_0x4987d5){var _0x46f626=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x46f626[_0x65c3('0x1f')](_0x25ce94)){return _0x3d691e;}else{throw new db['Sequelize'][(_0x65c3('0x20'))](_0x65c3('0x21'));}}else{return _0x3d691e;}}function respondWithRpcPromise(_0xe075c7,_0x513686,_0x7ff8ca,_0x169909){return new BPromise(function(_0x520267,_0x20dd83){var _0x4e5afa=_0x169909||client;return _0x4e5afa[_0x65c3('0x22')](_0xe075c7,_0x7ff8ca)[_0x65c3('0x23')](function(_0xc1b593){logger[_0x65c3('0x24')](_0x65c3('0x25'),_0x513686,_0x65c3('0x26'));logger[_0x65c3('0x27')](_0x65c3('0x28'),_0x513686,_0x65c3('0x26'),JSON['stringify'](_0xc1b593));if(_0xc1b593[_0x65c3('0x29')]){if(_0xc1b593['error'][_0x65c3('0x2a')]===0x1f4){logger[_0x65c3('0x29')](_0x65c3('0x25'),_0x513686,_0xc1b593[_0x65c3('0x29')]['message']);return _0x20dd83(_0xc1b593[_0x65c3('0x29')][_0x65c3('0x2b')]);}logger[_0x65c3('0x29')](_0x65c3('0x25'),_0x513686,_0xc1b593['error']['message']);return _0x520267(_0xc1b593[_0x65c3('0x29')][_0x65c3('0x2b')]);}else{logger[_0x65c3('0x24')](_0x65c3('0x25'),_0x513686,_0x65c3('0x26'));_0x520267(_0xc1b593['result'][_0x65c3('0x2b')]);}})[_0x65c3('0x2c')](function(_0x3f8921){logger[_0x65c3('0x29')](_0x65c3('0x25'),_0x513686,_0x3f8921);_0x20dd83(_0x3f8921);});});}function respondWithStatusCode(_0x3f2992,_0x389f8b){_0x389f8b=_0x389f8b||0xcc;return function(_0x1a4644){if(_0x1a4644){return _0x3f2992[_0x65c3('0x2d')](_0x389f8b);}return _0x3f2992[_0x65c3('0x2e')](_0x389f8b)[_0x65c3('0x2f')]();};}function respondWithResult(_0x304a98,_0x2c56f0){_0x2c56f0=_0x2c56f0||0xc8;return function(_0x219988){if(_0x219988){return _0x304a98['status'](_0x2c56f0)['json'](_0x219988);}};}function respondWithFilteredResult(_0x457a75,_0x107250){return function(_0x25c267){if(_0x25c267){var _0x2785e2=_0x25c267[_0x65c3('0x30')],_0x3d799a=_0x107250[_0x65c3('0x31')],_0xa25e5b=_0x107250['offset']+_0x107250['limit'],_0xd80ff;if(_0xa25e5b>=_0x2785e2){_0xa25e5b=_0x2785e2;_0xd80ff=0xc8;}else{_0xd80ff=0xce;}_0x457a75[_0x65c3('0x2e')](_0xd80ff);return _0x457a75[_0x65c3('0x32')]('Content-Range',_0x3d799a+'-'+_0xa25e5b+'/'+_0x2785e2)[_0x65c3('0x33')](_0x25c267);}return null;};}function patchUpdates(_0xd0ff42){return function(_0x47b5ca){try{jsonpatch[_0x65c3('0x34')](_0x47b5ca,_0xd0ff42,!![]);}catch(_0x5c32e8){return BPromise['reject'](_0x5c32e8);}return _0x47b5ca[_0x65c3('0x35')]();};}function saveUpdates(_0x9d2a22,_0x4e0a34){return function(_0x5c3ee2){if(_0x5c3ee2){return _0x5c3ee2['update'](_0x9d2a22)['then'](function(_0x259b05){return _0x259b05;});}return null;};}function removeEntity(_0x393f0a,_0xb3f6c6){return function(_0x534487){if(_0x534487){return _0x534487[_0x65c3('0x36')]()['then'](function(){var _0x2efb24=_0x534487[_0x65c3('0x37')]({'plain':!![]});var _0x1c5ca2=_0x65c3('0x38');return db[_0x65c3('0x39')][_0x65c3('0x36')]({'where':{'type':_0x1c5ca2,'resourceId':_0x2efb24['id']}})[_0x65c3('0x23')](function(){return _0x534487;});})[_0x65c3('0x23')](function(){_0x393f0a[_0x65c3('0x2e')](0xcc)[_0x65c3('0x2f')]();});}};}function handleEntityNotFound(_0x4abbb7,_0x2b6e8f){return function(_0x328551){if(!_0x328551){_0x4abbb7[_0x65c3('0x2d')](0x194);}return _0x328551;};}function handleError(_0x23305f,_0x3056af){_0x3056af=_0x3056af||0x1f4;return function(_0x5629bd){logger['error'](_0x5629bd[_0x65c3('0x3a')]);if(_0x5629bd['name']){delete _0x5629bd[_0x65c3('0x3b')];}_0x23305f[_0x65c3('0x2e')](_0x3056af)['send'](_0x5629bd);};}exports['index']=function(_0x240ed3,_0x34b5e2){var _0xbcaf56={'include':[{'model':db['Pause'],'as':_0x65c3('0x3c')}]},_0x4868af={},_0x5ba3af={'count':0x0,'rows':[]};var _0x503cbf=_[_0x65c3('0x3d')](db[_0x65c3('0x3e')][_0x65c3('0x3f')],function(_0x95591){return{'name':_0x95591[_0x65c3('0x40')],'type':_0x95591[_0x65c3('0x41')]['key']};});_0x4868af['model']=_[_0x65c3('0x3d')](_0x503cbf,_0x65c3('0x3b'));_0x4868af[_0x65c3('0x42')]=_[_0x65c3('0x43')](_0x240ed3[_0x65c3('0x42')]);_0x4868af[_0x65c3('0x44')]=_[_0x65c3('0x45')](_0x4868af['model'],_0x4868af[_0x65c3('0x42')]);_0xbcaf56[_0x65c3('0x46')]=_[_0x65c3('0x45')](_0x4868af[_0x65c3('0x47')],qs[_0x65c3('0x48')](_0x240ed3[_0x65c3('0x42')][_0x65c3('0x48')]));_0xbcaf56[_0x65c3('0x46')]=_0xbcaf56[_0x65c3('0x46')][_0x65c3('0x49')]?_0xbcaf56[_0x65c3('0x46')]:_0x4868af[_0x65c3('0x47')];if(!_0x240ed3[_0x65c3('0x42')]['hasOwnProperty'](_0x65c3('0x4a'))){_0xbcaf56[_0x65c3('0x4b')]=qs[_0x65c3('0x4b')](_0x240ed3['query'][_0x65c3('0x4b')]);_0xbcaf56['offset']=qs[_0x65c3('0x31')](_0x240ed3[_0x65c3('0x42')][_0x65c3('0x31')]);}_0xbcaf56['order']=qs[_0x65c3('0x4c')](_0x240ed3[_0x65c3('0x42')][_0x65c3('0x4c')]);_0xbcaf56[_0x65c3('0x4d')]=qs['filters'](_[_0x65c3('0x4e')](_0x240ed3[_0x65c3('0x42')],_0x4868af['filters']),_0x503cbf);if(_0x240ed3['query']['filter']){_0xbcaf56['where']=_[_0x65c3('0x4f')](_0xbcaf56['where'],{'$or':_['map'](_0x503cbf,function(_0x3652e1){if(_0x3652e1[_0x65c3('0x41')]!=='VIRTUAL'){var _0x3b9b0e={};_0x3b9b0e[_0x3652e1[_0x65c3('0x3b')]]={'$like':'%'+_0x240ed3[_0x65c3('0x42')][_0x65c3('0x50')]+'%'};return _0x3b9b0e;}})});}_0xbcaf56=_['merge']({},_0xbcaf56,_0x240ed3[_0x65c3('0x51')]);var _0xeb3715={'where':_0xbcaf56[_0x65c3('0x4d')]};return db[_0x65c3('0x3e')][_0x65c3('0x30')](_0xeb3715)[_0x65c3('0x23')](function(_0x52862f){_0x5ba3af[_0x65c3('0x30')]=_0x52862f;if(_0x240ed3[_0x65c3('0x42')][_0x65c3('0x52')]){_0xbcaf56[_0x65c3('0x53')]=[{'all':!![]}];}return db[_0x65c3('0x3e')][_0x65c3('0x54')](_0xbcaf56);})[_0x65c3('0x23')](function(_0x1fab04){_0x5ba3af['rows']=_0x1fab04;return _0x5ba3af;})['then'](respondWithFilteredResult(_0x34b5e2,_0xbcaf56))[_0x65c3('0x2c')](handleError(_0x34b5e2,null));};exports[_0x65c3('0x55')]=function(_0x4ee1ad,_0x151638){var _0x11740e={'raw':![],'where':{'id':_0x4ee1ad[_0x65c3('0x56')]['id']},'include':[{'model':db[_0x65c3('0x57')],'as':_0x65c3('0x3c')}]},_0x38bd7e={};_0x38bd7e[_0x65c3('0x47')]=_[_0x65c3('0x43')](db['OpenchannelAccount'][_0x65c3('0x3f')]);_0x38bd7e[_0x65c3('0x42')]=_[_0x65c3('0x43')](_0x4ee1ad[_0x65c3('0x42')]);_0x38bd7e[_0x65c3('0x44')]=_[_0x65c3('0x45')](_0x38bd7e['model'],_0x38bd7e['query']);_0x11740e[_0x65c3('0x46')]=_['intersection'](_0x38bd7e['model'],qs[_0x65c3('0x48')](_0x4ee1ad['query']['fields']));_0x11740e[_0x65c3('0x46')]=_0x11740e[_0x65c3('0x46')][_0x65c3('0x49')]?_0x11740e[_0x65c3('0x46')]:_0x38bd7e['model'];if(_0x4ee1ad[_0x65c3('0x42')][_0x65c3('0x52')]){_0x11740e[_0x65c3('0x53')]=[{'all':!![]}];}_0x11740e=_['merge']({},_0x11740e,_0x4ee1ad[_0x65c3('0x51')]);return db[_0x65c3('0x3e')]['find'](_0x11740e)[_0x65c3('0x23')](handleEntityNotFound(_0x151638,null))['then'](respondWithResult(_0x151638,null))['catch'](handleError(_0x151638,null));};exports['create']=function(_0x5a8295,_0xcc3294){return db[_0x65c3('0x3e')][_0x65c3('0x58')](_0x5a8295[_0x65c3('0x59')],{})[_0x65c3('0x23')](function(_0x35e2b7){var _0x3a1a0d=_0x5a8295[_0x65c3('0x5a')][_0x65c3('0x37')]({'plain':!![]});if(!_0x3a1a0d)throw new Error(_0x65c3('0x5b'));if(_0x3a1a0d[_0x65c3('0x5c')]==='user'){var _0x52fdf9=_0x35e2b7[_0x65c3('0x37')]({'plain':!![]});var _0x53cc11=_0x65c3('0x38');return db[_0x65c3('0x5d')][_0x65c3('0x5e')]({'where':{'name':_0x53cc11,'userProfileId':_0x3a1a0d[_0x65c3('0x5f')]},'raw':!![]})['then'](function(_0x5602f0){if(_0x5602f0&&_0x5602f0[_0x65c3('0x60')]===0x0){return db[_0x65c3('0x39')][_0x65c3('0x58')]({'name':_0x52fdf9['name'],'resourceId':_0x52fdf9['id'],'type':_0x5602f0['name'],'sectionId':_0x5602f0['id']},{})[_0x65c3('0x23')](function(){return _0x35e2b7;});}else{return _0x35e2b7;}})[_0x65c3('0x2c')](function(_0x236ad6){logger[_0x65c3('0x29')](_0x65c3('0x61'),_0x236ad6);throw _0x236ad6;});}return _0x35e2b7;})[_0x65c3('0x23')](respondWithResult(_0xcc3294,0xc9))[_0x65c3('0x2c')](handleError(_0xcc3294,null));};exports[_0x65c3('0x62')]=function(_0x22ac52,_0x44d17b){if(_0x22ac52[_0x65c3('0x59')]['id']){delete _0x22ac52['body']['id'];}return db['OpenchannelAccount'][_0x65c3('0x5e')]({'where':{'id':_0x22ac52[_0x65c3('0x56')]['id']},'include':[{'model':db[_0x65c3('0x57')],'as':_0x65c3('0x3c')}]})[_0x65c3('0x23')](handleEntityNotFound(_0x44d17b,null))[_0x65c3('0x23')](saveUpdates(_0x22ac52['body'],null))[_0x65c3('0x23')](respondWithResult(_0x44d17b,null))[_0x65c3('0x2c')](handleError(_0x44d17b,null));};exports[_0x65c3('0x36')]=function(_0x861c50,_0x1fc6dc){return db[_0x65c3('0x3e')]['find']({'where':{'id':_0x861c50[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0x1fc6dc,null))[_0x65c3('0x23')](removeEntity(_0x1fc6dc,null))['catch'](handleError(_0x1fc6dc,null));};exports[_0x65c3('0x63')]=function(_0x4819c9,_0x337d95){return db[_0x65c3('0x3e')][_0x65c3('0x63')]()[_0x65c3('0x23')](respondWithResult(_0x337d95,null))[_0x65c3('0x2c')](handleError(_0x337d95,null));};exports['addDisposition']=function(_0x1a0334,_0x562a77,_0x4272a4){if(_0x1a0334[_0x65c3('0x59')]['id']){delete _0x1a0334[_0x65c3('0x59')]['id'];}return db[_0x65c3('0x3e')][_0x65c3('0x5e')]({'where':{'id':_0x1a0334[_0x65c3('0x56')]['id']}})['then'](handleEntityNotFound(_0x562a77,null))['then'](function(_0x1b71bc){if(_0x1b71bc){_0x1a0334[_0x65c3('0x59')][_0x65c3('0x64')]=_0x1b71bc['id'];return db['Disposition'][_0x65c3('0x58')](_0x1a0334[_0x65c3('0x59')]);}})[_0x65c3('0x23')](respondWithResult(_0x562a77,null))[_0x65c3('0x2c')](handleError(_0x562a77,null));};exports[_0x65c3('0x65')]=function(_0x77dd11,_0xc3df57,_0x2f7dc6){var _0x2300ae={'raw':![],'where':{}};var _0x1e1108={};var _0xf0b1c8={'count':0x0,'rows':[]};return db['OpenchannelAccount']['findOne']({'where':{'id':_0x77dd11[_0x65c3('0x56')]['id']}})['then'](handleEntityNotFound(_0xc3df57,null))[_0x65c3('0x23')](function(_0xdd9d4a){if(_0xdd9d4a){_0x1e1108[_0x65c3('0x47')]=_['keys'](db[_0x65c3('0x66')][_0x65c3('0x3f')]);_0x1e1108[_0x65c3('0x42')]=_[_0x65c3('0x43')](_0x77dd11[_0x65c3('0x42')]);_0x1e1108[_0x65c3('0x44')]=_[_0x65c3('0x45')](_0x1e1108[_0x65c3('0x47')],_0x1e1108['query']);_0x2300ae[_0x65c3('0x46')]=_[_0x65c3('0x45')](_0x1e1108[_0x65c3('0x47')],qs[_0x65c3('0x48')](_0x77dd11[_0x65c3('0x42')][_0x65c3('0x48')]));_0x2300ae[_0x65c3('0x46')]=_0x2300ae[_0x65c3('0x46')][_0x65c3('0x49')]?_0x2300ae[_0x65c3('0x46')]:_0x1e1108['model'];if(!_0x77dd11[_0x65c3('0x42')][_0x65c3('0x67')](_0x65c3('0x4a'))){_0x2300ae[_0x65c3('0x4b')]=qs[_0x65c3('0x4b')](_0x77dd11[_0x65c3('0x42')][_0x65c3('0x4b')]);_0x2300ae['offset']=qs[_0x65c3('0x31')](_0x77dd11[_0x65c3('0x42')][_0x65c3('0x31')]);}_0x2300ae['order']=qs[_0x65c3('0x4c')](_0x77dd11[_0x65c3('0x42')][_0x65c3('0x4c')]);_0x2300ae[_0x65c3('0x4d')]=qs['filters'](_[_0x65c3('0x4e')](_0x77dd11[_0x65c3('0x42')],_0x1e1108['filters']));_0x2300ae['where'][_0x65c3('0x68')]=_0xdd9d4a['id'];if(_0x77dd11[_0x65c3('0x42')][_0x65c3('0x50')]){_0x2300ae[_0x65c3('0x4d')]=_[_0x65c3('0x4f')](_0x2300ae[_0x65c3('0x4d')],{'$or':_[_0x65c3('0x3d')](_0x2300ae[_0x65c3('0x46')],function(_0x43111a){var _0xd959e4={};_0xd959e4[_0x43111a]={'$like':'%'+_0x77dd11['query'][_0x65c3('0x50')]+'%'};return _0xd959e4;})});}_0x2300ae=_[_0x65c3('0x4f')]({},_0x2300ae,_0x77dd11[_0x65c3('0x51')]);return db[_0x65c3('0x66')][_0x65c3('0x30')]({'where':_0x2300ae['where']})['then'](function(_0x489e15){_0xf0b1c8['count']=_0x489e15;if(_0x77dd11[_0x65c3('0x42')][_0x65c3('0x52')]){_0x2300ae['include']=[{'all':!![]}];}return db[_0x65c3('0x66')]['findAll'](_0x2300ae);})[_0x65c3('0x23')](function(_0x4c2ce0){_0xf0b1c8[_0x65c3('0x69')]=_0x4c2ce0;return _0xf0b1c8;});}})[_0x65c3('0x23')](respondWithFilteredResult(_0xc3df57,_0x2300ae))[_0x65c3('0x2c')](handleError(_0xc3df57,null));};exports['removeDispositions']=function(_0x5a86f1,_0x3f6183,_0x57d217){return db[_0x65c3('0x3e')][_0x65c3('0x5e')]({'where':{'id':_0x5a86f1[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0x3f6183,null))[_0x65c3('0x23')](function(_0x262be2){if(_0x262be2){return _0x262be2[_0x65c3('0x6a')](_0x5a86f1[_0x65c3('0x42')][_0x65c3('0x6b')]);}})['then'](respondWithStatusCode(_0x3f6183,null))['catch'](handleError(_0x3f6183,null));};exports[_0x65c3('0x6c')]=function(_0x17f47a,_0xc87543,_0x5e4b7b){if(_0x17f47a[_0x65c3('0x59')]['id']){delete _0x17f47a[_0x65c3('0x59')]['id'];}return db[_0x65c3('0x3e')]['find']({'where':{'id':_0x17f47a['params']['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0xc87543,null))[_0x65c3('0x23')](function(_0x1f69e7){if(_0x1f69e7){_0x17f47a[_0x65c3('0x59')][_0x65c3('0x68')]=_0x1f69e7['id'];return db[_0x65c3('0x6d')][_0x65c3('0x58')](_0x17f47a['body']);}})[_0x65c3('0x23')](respondWithResult(_0xc87543,null))[_0x65c3('0x2c')](handleError(_0xc87543,null));};exports[_0x65c3('0x6e')]=function(_0x3dbd06,_0x280c4b,_0x4446c8){var _0x22444d={'raw':![],'where':{}};var _0x4fbf70={};var _0x574d8a={'count':0x0,'rows':[]};return db[_0x65c3('0x3e')][_0x65c3('0x6f')]({'where':{'id':_0x3dbd06[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0x280c4b,null))['then'](function(_0x39360d){if(_0x39360d){_0x4fbf70[_0x65c3('0x47')]=_[_0x65c3('0x43')](db[_0x65c3('0x6d')][_0x65c3('0x3f')]);_0x4fbf70[_0x65c3('0x42')]=_['keys'](_0x3dbd06[_0x65c3('0x42')]);_0x4fbf70['filters']=_[_0x65c3('0x45')](_0x4fbf70[_0x65c3('0x47')],_0x4fbf70['query']);_0x22444d[_0x65c3('0x46')]=_[_0x65c3('0x45')](_0x4fbf70[_0x65c3('0x47')],qs[_0x65c3('0x48')](_0x3dbd06['query'][_0x65c3('0x48')]));_0x22444d[_0x65c3('0x46')]=_0x22444d[_0x65c3('0x46')][_0x65c3('0x49')]?_0x22444d[_0x65c3('0x46')]:_0x4fbf70[_0x65c3('0x47')];if(!_0x3dbd06[_0x65c3('0x42')][_0x65c3('0x67')](_0x65c3('0x4a'))){_0x22444d[_0x65c3('0x4b')]=qs['limit'](_0x3dbd06['query'][_0x65c3('0x4b')]);_0x22444d[_0x65c3('0x31')]=qs[_0x65c3('0x31')](_0x3dbd06[_0x65c3('0x42')][_0x65c3('0x31')]);}_0x22444d['order']=qs['sort'](_0x3dbd06[_0x65c3('0x42')]['sort']);_0x22444d['where']=qs['filters'](_[_0x65c3('0x4e')](_0x3dbd06[_0x65c3('0x42')],_0x4fbf70[_0x65c3('0x44')]));_0x22444d[_0x65c3('0x4d')][_0x65c3('0x68')]=_0x39360d['id'];if(_0x3dbd06[_0x65c3('0x42')][_0x65c3('0x50')]){_0x22444d[_0x65c3('0x4d')]=_[_0x65c3('0x4f')](_0x22444d['where'],{'$or':_['map'](_0x22444d[_0x65c3('0x46')],function(_0xbe54a3){var _0xb2420b={};_0xb2420b[_0xbe54a3]={'$like':'%'+_0x3dbd06[_0x65c3('0x42')][_0x65c3('0x50')]+'%'};return _0xb2420b;})});}_0x22444d=_[_0x65c3('0x4f')]({},_0x22444d,_0x3dbd06[_0x65c3('0x51')]);return db[_0x65c3('0x6d')]['count']({'where':_0x22444d['where']})[_0x65c3('0x23')](function(_0x51c27d){_0x574d8a[_0x65c3('0x30')]=_0x51c27d;if(_0x3dbd06[_0x65c3('0x42')]['includeAll']){_0x22444d[_0x65c3('0x53')]=[{'all':!![]}];}return db[_0x65c3('0x6d')][_0x65c3('0x54')](_0x22444d);})[_0x65c3('0x23')](function(_0x4f916b){_0x574d8a[_0x65c3('0x69')]=_0x4f916b;return _0x574d8a;});}})['then'](respondWithFilteredResult(_0x280c4b,_0x22444d))[_0x65c3('0x2c')](handleError(_0x280c4b,null));};exports[_0x65c3('0x70')]=function(_0x52f66d,_0x40aee1,_0x8937c0){return db[_0x65c3('0x3e')][_0x65c3('0x5e')]({'where':{'id':_0x52f66d[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0x40aee1,null))[_0x65c3('0x23')](function(_0x15d9ef){if(_0x15d9ef){return _0x15d9ef['removeAnswers'](_0x52f66d['query'][_0x65c3('0x6b')]);}})[_0x65c3('0x23')](respondWithStatusCode(_0x40aee1,null))['catch'](handleError(_0x40aee1,null));};exports['notify']=function(_0x5afa6c,_0x23b972,_0x39d210){var _0x2d0a07={'body':_0x5afa6c[_0x65c3('0x59')],'channel':_0x65c3('0x71')};var _0x106e05=[];var _0x5ec534=[];var _0x4a92ee={};var _0x4af5c8=![];return db[_0x65c3('0x72')]['describe']()['then'](function(_0x36a025){if(!_0x36a025){throw new db[(_0x65c3('0x73'))]['ValidationError']('no\x20available\x20attributes');}_0x106e05=_[_0x65c3('0x74')](_[_0x65c3('0x43')](_0x36a025),[_0x65c3('0x75'),_0x65c3('0x76')]);_0x5ec534=_['difference'](_[_0x65c3('0x43')](_0x36a025),[_0x65c3('0x75'),_0x65c3('0x76'),_0x65c3('0x77'),'ListId']);if(_0x5afa6c[_0x65c3('0x59')]['id']){delete _0x5afa6c[_0x65c3('0x59')]['id'];}if(_[_0x65c3('0x78')](_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x79')])){throw new db[(_0x65c3('0x73'))][(_0x65c3('0x20'))]('from\x20is\x20mandatory');}if(_[_0x65c3('0x78')](_0x5afa6c[_0x65c3('0x59')]['body'])||_0x5afa6c['body']['body']===''){throw new db[(_0x65c3('0x73'))][(_0x65c3('0x20'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x65c3('0x78')](_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x7a')])){throw new db[(_0x65c3('0x73'))][(_0x65c3('0x20'))](_0x65c3('0x7b')+_0x5ec534);}if(!_[_0x65c3('0x7c')](_0x5ec534,_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x7a')])){throw new db[(_0x65c3('0x73'))][(_0x65c3('0x20'))](_0x65c3('0x7d')+_0x5ec534);}_0x4a92ee[_0x5afa6c['body'][_0x65c3('0x7a')]]=_0x5afa6c[_0x65c3('0x59')]['from'];})['then'](function(){return db['OpenchannelAccount']['find']({'where':{'id':_0x5afa6c[_0x65c3('0x56')]['id']},'include':[{'model':db[_0x65c3('0x7e')],'as':_0x65c3('0x7f'),'include':[{'model':db[_0x65c3('0x72')],'as':_0x65c3('0x80'),'where':_0x4a92ee,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db[_0x65c3('0x81')],'as':'Applications'}]});})['then'](handleEntityNotFound(_0x23b972,null))[_0x65c3('0x23')](function(_0x1fd2ba){if(_0x1fd2ba&&_0x1fd2ba['List']){_0x2d0a07[_0x65c3('0x82')]=_0x1fd2ba;_0x2d0a07[_0x65c3('0x83')]=_0x1fd2ba[_0x65c3('0x84')];_0x2d0a07[_0x65c3('0x85')]=_0x1fd2ba['List'];_0x2d0a07[_0x65c3('0x83')]=_[_0x65c3('0x86')](_0x2d0a07['applications'],[_0x65c3('0x87')],[_0x65c3('0x88')]);if(_0x2d0a07[_0x65c3('0x82')][_0x65c3('0x84')]){delete _0x2d0a07[_0x65c3('0x82')][_0x65c3('0x84')];}if(_0x2d0a07[_0x65c3('0x82')][_0x65c3('0x7f')]&&_0x2d0a07[_0x65c3('0x82')][_0x65c3('0x7f')][_0x65c3('0x80')]['length']){return _0x2d0a07[_0x65c3('0x82')][_0x65c3('0x7f')][_0x65c3('0x80')][0x0];}var _0x5e15c6=_[_0x65c3('0x17')](_0x5afa6c[_0x65c3('0x59')],{'firstName':_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x79')],'ListId':_0x1fd2ba[_0x65c3('0x89')]});_0x5e15c6[_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x7a')]]=_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x79')];return db[_0x65c3('0x72')][_0x65c3('0x58')](_0x5e15c6,{'fields':_0x106e05,'raw':!![]});}})[_0x65c3('0x23')](handleEntityNotFound(_0x23b972,null))['then'](function(_0xa3c33a){_0x2d0a07['contact']=_0xa3c33a;if(_0xa3c33a){var _0x8733e8={'ContactId':_0xa3c33a['id'],'OpenchannelAccountId':_0x5afa6c[_0x65c3('0x56')]['id'],'from':(_0xa3c33a[_0x65c3('0x8a')]||'')+'\x20'+(_0xa3c33a[_0x65c3('0x8b')]||'')};var _0xaea13a={'OpenchannelAccountId':_0x5afa6c[_0x65c3('0x56')]['id'],'closed':![]};if(_0x5afa6c[_0x65c3('0x59')]['threadId']){_0xaea13a['threadId']=_0x5afa6c['body'][_0x65c3('0x8c')];return db[_0x65c3('0x8d')][_0x65c3('0x5e')]({'where':_0xaea13a})[_0x65c3('0x23')](function(_0x1711f1){if(_0x1711f1){return[_0x1711f1,![]];}_0x8733e8[_0x65c3('0x8c')]=_0x5afa6c['body'][_0x65c3('0x8c')];_0x8733e8[_0x65c3('0x8e')]=_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x8e')];return db[_0x65c3('0x8d')]['create'](_0x8733e8)['then'](function(_0x251167){return[_0x251167,!![]];});});}else{_0xaea13a[_0x65c3('0x8c')]=null;}_0xaea13a[_0x65c3('0x8f')]=_0xa3c33a['id'];return db[_0x65c3('0x8d')]['find']({'where':_0xaea13a})[_0x65c3('0x23')](function(_0x58fb86){if(_0x58fb86){return[_0x58fb86,![]];}return db[_0x65c3('0x8d')]['create'](_0x8733e8)[_0x65c3('0x23')](function(_0x331b6e){return[_0x331b6e,!![]];});});}})[_0x65c3('0x90')](function(_0x1afa8b,_0x19b88b){if(_0x1afa8b){_0x4af5c8=_0x19b88b;if(!_0x19b88b){var _0x496cb7={'from':(_0x2d0a07[_0x65c3('0x91')]['firstName']||'')+'\x20'+(_0x2d0a07[_0x65c3('0x91')][_0x65c3('0x8b')]||'')};if(_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x8c')]&&_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x92')]&&_0x5afa6c[_0x65c3('0x59')][_0x65c3('0x8c')]!=_0x5afa6c['body'][_0x65c3('0x92')]){_0x496cb7[_0x65c3('0x8c')]=_0x5afa6c['body'][_0x65c3('0x92')];}return _0x1afa8b[_0x65c3('0x62')](_0x496cb7);}else{return _0x1afa8b;}}})[_0x65c3('0x23')](function(_0x1f5f61){_0x2d0a07[_0x65c3('0x93')]=_0x1f5f61[_0x65c3('0x37')]({'plain':!![]});_0x2d0a07[_0x65c3('0x93')][_0x65c3('0x94')]=_0x4af5c8;if(_0x2d0a07[_0x65c3('0x93')]['created']){if(_0x2d0a07[_0x65c3('0x82')][_0x65c3('0x95')]){_0x2d0a07['applications'][_0x65c3('0x96')]({'id':0x0,'priority':_0x2d0a07[_0x65c3('0x83')][_0x65c3('0x49')]+0x1,'app':'close','appdata':'unmanaged','interval':_0x65c3('0x97')});}}return db['OpenchannelMessage'][_0x65c3('0x58')]({'body':_0x5afa6c[_0x65c3('0x59')]['body'],'OpenchannelAccountId':_0x5afa6c[_0x65c3('0x56')]['id'],'OpenchannelInteractionId':_0x1f5f61['id'],'direction':'in','ContactId':_0x2d0a07[_0x65c3('0x91')]['id'],'AttachmentId':_0x5afa6c['body'][_0x65c3('0x98')]});})[_0x65c3('0x23')](function(_0x3e3388){_0x2d0a07[_0x65c3('0x2b')]=_0x3e3388;if(_0x2d0a07[_0x65c3('0x93')][_0x65c3('0x99')]){return db[_0x65c3('0x9a')][_0x65c3('0x5e')]({'attributes':['id',_0x65c3('0x3b')],'where':{'id':_0x2d0a07['interaction']['UserId']}})[_0x65c3('0x23')](function(_0x47478a){if(_0x47478a){_0x2d0a07[_0x65c3('0x83')][_0x65c3('0x9b')]({'id':0x0,'priority':0x0,'app':_0x65c3('0x9c'),'appdata':_0x47478a[_0x65c3('0x3b')]+','+(_0x2d0a07['account'][_0x65c3('0x9d')]||0xa),'interval':_0x65c3('0x97')});_0x2d0a07[_0x65c3('0x9e')]=![];}return respondWithRpcPromise(_0x65c3('0x9f'),_0x65c3('0xa0'),_0x2d0a07);});}return respondWithRpcPromise('Start',_0x65c3('0xa0'),_0x2d0a07);})[_0x65c3('0x23')](function(_0x54a498){respondWithRpcPromise('EventManager','EventManager',{'event':_0x65c3('0xa1'),'message':_0x54a498},client9002);return _0x54a498;})['then'](respondWithResult(_0x23b972,null))['catch'](handleError(_0x23b972,null));};exports[_0x65c3('0xa2')]=function(_0x59715c,_0x1b79d5,_0x5751ea){return db[_0x65c3('0x3e')]['findOne']({'where':{'id':_0x59715c[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0x1b79d5,null))[_0x65c3('0x23')](function(_0x5287eb){if(_0x5287eb){return db[_0x65c3('0xa3')][_0x65c3('0xa4')](function(_0x325ba2){return db[_0x65c3('0x81')]['destroy']({'where':{'OpenchannelAccountId':_0x59715c[_0x65c3('0x56')]['id']},'transaction':_0x325ba2})['then'](function(_0x1ca398){var _0x453880=_[_0x65c3('0x3d')](_0x59715c[_0x65c3('0x59')],function(_0x226b1a){_0x226b1a[_0x65c3('0x68')]=_0x59715c[_0x65c3('0x56')]['id'];return _0x226b1a;});return db['OpenchannelApplication'][_0x65c3('0xa5')](_0x453880,{'transaction':_0x325ba2});});})[_0x65c3('0x23')](function(){return db[_0x65c3('0x81')][_0x65c3('0xa6')]({'where':{'OpenchannelAccountId':_0x59715c[_0x65c3('0x56')]['id']},'order':'priority'});});}})[_0x65c3('0x23')](respondWithResult(_0x1b79d5,null))[_0x65c3('0x2c')](handleError(_0x1b79d5,null));};exports[_0x65c3('0xa7')]=function(_0x2964ee,_0xabdc47,_0x3d2efd){var _0x117f7e={};var _0x11f77e={};var _0x4a18f0;var _0x134204;return db['OpenchannelAccount'][_0x65c3('0x6f')]({'where':{'id':_0x2964ee[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0xabdc47,null))['then'](function(_0x3c780a){if(_0x3c780a){_0x4a18f0=_0x3c780a;_0x11f77e['model']=_[_0x65c3('0x43')](db[_0x65c3('0x81')][_0x65c3('0x3f')]);_0x11f77e[_0x65c3('0x42')]=_[_0x65c3('0x43')](_0x2964ee[_0x65c3('0x42')]);_0x11f77e[_0x65c3('0x44')]=_['intersection'](_0x11f77e[_0x65c3('0x47')],_0x11f77e[_0x65c3('0x42')]);_0x117f7e[_0x65c3('0x46')]=_[_0x65c3('0x45')](_0x11f77e[_0x65c3('0x47')],qs[_0x65c3('0x48')](_0x2964ee[_0x65c3('0x42')][_0x65c3('0x48')]));_0x117f7e[_0x65c3('0x46')]=_0x117f7e[_0x65c3('0x46')][_0x65c3('0x49')]?_0x117f7e[_0x65c3('0x46')]:_0x11f77e[_0x65c3('0x47')];_0x117f7e[_0x65c3('0xa8')]=qs[_0x65c3('0x4c')](_0x2964ee['query']['sort']);_0x117f7e['where']=qs[_0x65c3('0x44')](_['pick'](_0x2964ee[_0x65c3('0x42')],_0x11f77e[_0x65c3('0x44')]));if(_0x2964ee[_0x65c3('0x42')][_0x65c3('0x50')]){_0x117f7e[_0x65c3('0x4d')]=_[_0x65c3('0x4f')](_0x117f7e[_0x65c3('0x4d')],{'$or':_['map'](_0x117f7e[_0x65c3('0x46')],function(_0x463103){var _0x58ee30={};_0x58ee30[_0x463103]={'$like':'%'+_0x2964ee['query']['filter']+'%'};return _0x58ee30;})});}_0x117f7e=_['merge']({},_0x117f7e,_0x2964ee[_0x65c3('0x51')]);return _0x4a18f0[_0x65c3('0xa7')](_0x117f7e);}})[_0x65c3('0x23')](function(_0x445c7f){if(_0x445c7f){_0x134204=_0x445c7f[_0x65c3('0x49')];if(!_0x2964ee['query'][_0x65c3('0x67')](_0x65c3('0x4a'))){_0x117f7e[_0x65c3('0x4b')]=qs['limit'](_0x2964ee[_0x65c3('0x42')][_0x65c3('0x4b')]);_0x117f7e[_0x65c3('0x31')]=qs[_0x65c3('0x31')](_0x2964ee['query'][_0x65c3('0x31')]);}return _0x4a18f0[_0x65c3('0xa7')](_0x117f7e);}})[_0x65c3('0x23')](function(_0x576135){if(_0x576135){return _0x576135?{'count':_0x134204,'rows':_0x576135}:null;}})['then'](respondWithResult(_0xabdc47,null))['catch'](handleError(_0xabdc47,null));};exports[_0x65c3('0xa9')]=function(_0x20df38,_0x2c5d30,_0xea27ac){var _0x6cabaf={'raw':![],'where':{}};var _0x2bc041={};var _0x44a9e8={'count':0x0,'rows':[]};return db[_0x65c3('0x3e')][_0x65c3('0x6f')]({'where':{'id':_0x20df38[_0x65c3('0x56')]['id']}})['then'](handleEntityNotFound(_0x2c5d30,null))[_0x65c3('0x23')](function(_0x4508c3){if(_0x4508c3){_0x2bc041[_0x65c3('0x47')]=_[_0x65c3('0x43')](db['OpenchannelInteraction'][_0x65c3('0x3f')]);_0x2bc041[_0x65c3('0x42')]=_[_0x65c3('0x43')](_0x20df38[_0x65c3('0x42')]);_0x2bc041[_0x65c3('0x44')]=_[_0x65c3('0x45')](_0x2bc041[_0x65c3('0x47')],_0x2bc041[_0x65c3('0x42')]);_0x6cabaf['attributes']=_[_0x65c3('0x45')](_0x2bc041[_0x65c3('0x47')],qs[_0x65c3('0x48')](_0x20df38[_0x65c3('0x42')][_0x65c3('0x48')]));_0x6cabaf['attributes']=_0x6cabaf[_0x65c3('0x46')][_0x65c3('0x49')]?_0x6cabaf['attributes']:_0x2bc041[_0x65c3('0x47')];if(!_0x20df38[_0x65c3('0x42')]['hasOwnProperty']('nolimit')){_0x6cabaf['limit']=qs[_0x65c3('0x4b')](_0x20df38[_0x65c3('0x42')][_0x65c3('0x4b')]);_0x6cabaf[_0x65c3('0x31')]=qs['offset'](_0x20df38[_0x65c3('0x42')][_0x65c3('0x31')]);}_0x6cabaf[_0x65c3('0xa8')]=qs['sort'](_0x20df38[_0x65c3('0x42')][_0x65c3('0x4c')]);_0x6cabaf['where']=qs[_0x65c3('0x44')](_[_0x65c3('0x4e')](_0x20df38[_0x65c3('0x42')],_0x2bc041[_0x65c3('0x44')]));_0x6cabaf[_0x65c3('0x4d')][_0x65c3('0x68')]=_0x4508c3['id'];if(_0x20df38[_0x65c3('0x42')][_0x65c3('0x50')]){_0x6cabaf[_0x65c3('0x4d')]=_['merge'](_0x6cabaf[_0x65c3('0x4d')],{'$or':_['map'](_0x6cabaf[_0x65c3('0x46')],function(_0x3058bb){var _0x274818={};_0x274818[_0x3058bb]={'$like':'%'+_0x20df38['query']['filter']+'%'};return _0x274818;})});}_0x6cabaf=_[_0x65c3('0x4f')]({},_0x6cabaf,_0x20df38['options']);return db[_0x65c3('0x8d')][_0x65c3('0x30')]({'where':_0x6cabaf['where']})[_0x65c3('0x23')](function(_0x2cc348){_0x44a9e8[_0x65c3('0x30')]=_0x2cc348;if(_0x20df38[_0x65c3('0x42')][_0x65c3('0x52')]){_0x6cabaf['include']=[{'model':db[_0x65c3('0x72')],'as':'Contact','required':![]},{'model':db[_0x65c3('0x9a')],'as':'Owner','attributes':[_0x65c3('0x3b'),_0x65c3('0xaa'),'internal'],'required':![]},{'model':db['Tag'],'as':'Tags','attributes':['id',_0x65c3('0x3b'),_0x65c3('0xab')],'where':_0x20df38[_0x65c3('0x42')][_0x65c3('0xac')]?{'id':_0x20df38[_0x65c3('0x42')][_0x65c3('0xac')]}:undefined,'required':_0x20df38['query'][_0x65c3('0xac')]?!![]:![]}];}return db[_0x65c3('0x8d')][_0x65c3('0x54')](_0x6cabaf);})[_0x65c3('0x23')](function(_0x7ecbb9){_0x44a9e8[_0x65c3('0x69')]=_0x7ecbb9;return _0x44a9e8;});}})['then'](respondWithFilteredResult(_0x2c5d30,_0x6cabaf))[_0x65c3('0x2c')](handleError(_0x2c5d30,null));};exports[_0x65c3('0xad')]=function(_0x3efc5d,_0x3852c9,_0x1435f3){return db[_0x65c3('0x3e')][_0x65c3('0x5e')]({'where':{'id':_0x3efc5d[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0x3852c9,null))[_0x65c3('0x23')](function(_0x198649){if(_0x198649){return _0x198649['addAgents'](_0x3efc5d[_0x65c3('0x59')]['ids'],_['omit'](_0x3efc5d['body'],['ids','id'])||{})[_0x65c3('0x90')](function(_0x3a0889){for(var _0x2324e6=0x0;_0x2324e6<_0x3efc5d[_0x65c3('0x59')][_0x65c3('0x6b')][_0x65c3('0x49')];_0x2324e6+=0x1){socket[_0x65c3('0xae')](_0x65c3('0xaf'),{'UserId':_0x3efc5d[_0x65c3('0x59')]['ids'][_0x2324e6],'OpenchannelAccountId':_0x3efc5d['params']['id']});}return _0x3a0889;});}})[_0x65c3('0x23')](respondWithResult(_0x3852c9,null))[_0x65c3('0x2c')](handleError(_0x3852c9,null));};exports[_0x65c3('0xb0')]=function(_0x5f270c,_0x2b7891,_0x2040f6){return db['OpenchannelAccount'][_0x65c3('0x5e')]({'where':{'id':_0x5f270c['params']['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0x2b7891,null))[_0x65c3('0x23')](function(_0x5447ab){if(_0x5447ab){return _0x5447ab[_0x65c3('0xb0')](_0x5f270c[_0x65c3('0x42')][_0x65c3('0x6b')])[_0x65c3('0x23')](function(){if(_['isArray'](_0x5f270c[_0x65c3('0x42')][_0x65c3('0x6b')])){for(var _0x1f9c49=0x0;_0x1f9c49<_0x5f270c['query'][_0x65c3('0x6b')]['length'];_0x1f9c49+=0x1){socket['emit'](_0x65c3('0xb1'),{'UserId':Number(_0x5f270c[_0x65c3('0x42')]['ids'][_0x1f9c49]),'OpenchannelAccountId':Number(_0x5f270c[_0x65c3('0x56')]['id'])});}}else{socket[_0x65c3('0xae')](_0x65c3('0xb1'),{'UserId':Number(_0x5f270c[_0x65c3('0x42')][_0x65c3('0x6b')]),'OpenchannelAccountId':Number(_0x5f270c[_0x65c3('0x56')]['id'])});}});}})[_0x65c3('0x23')](respondWithStatusCode(_0x2b7891,null))['catch'](handleError(_0x2b7891,null));};exports[_0x65c3('0xb2')]=function(_0x1f0da,_0x5332f6,_0x1b56b3){var _0x370c0f={};var _0x21f1de={};var _0x5f02a0;var _0x2f2a0b;return db[_0x65c3('0x3e')][_0x65c3('0x6f')]({'where':{'id':_0x1f0da[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0x5332f6,null))['then'](function(_0x2990ea){if(_0x2990ea){_0x5f02a0=_0x2990ea;_0x21f1de[_0x65c3('0x47')]=_['keys'](db[_0x65c3('0x9a')][_0x65c3('0x3f')]);_0x21f1de[_0x65c3('0x42')]=_[_0x65c3('0x43')](_0x1f0da[_0x65c3('0x42')]);_0x21f1de[_0x65c3('0x44')]=_[_0x65c3('0x45')](_0x21f1de[_0x65c3('0x47')],_0x21f1de[_0x65c3('0x42')]);_0x370c0f[_0x65c3('0x46')]=_[_0x65c3('0x45')](_0x21f1de['model'],qs['fields'](_0x1f0da[_0x65c3('0x42')]['fields']));_0x370c0f[_0x65c3('0x46')]=_0x370c0f[_0x65c3('0x46')][_0x65c3('0x49')]?_0x370c0f[_0x65c3('0x46')]:_0x21f1de[_0x65c3('0x47')];_0x370c0f[_0x65c3('0xa8')]=qs[_0x65c3('0x4c')](_0x1f0da[_0x65c3('0x42')][_0x65c3('0x4c')]);_0x370c0f['where']=qs[_0x65c3('0x44')](_[_0x65c3('0x4e')](_0x1f0da[_0x65c3('0x42')],_0x21f1de[_0x65c3('0x44')]));if(_0x1f0da[_0x65c3('0x42')][_0x65c3('0x50')]){_0x370c0f[_0x65c3('0x4d')]=_[_0x65c3('0x4f')](_0x370c0f[_0x65c3('0x4d')],{'$or':_[_0x65c3('0x3d')](_0x370c0f[_0x65c3('0x46')],function(_0x3062a9){var _0x3f8bca={};_0x3f8bca[_0x3062a9]={'$like':'%'+_0x1f0da[_0x65c3('0x42')][_0x65c3('0x50')]+'%'};return _0x3f8bca;})});}_0x370c0f=_[_0x65c3('0x4f')]({},_0x370c0f,_0x1f0da[_0x65c3('0x51')]);return _0x5f02a0[_0x65c3('0xb2')](_0x370c0f);}})[_0x65c3('0x23')](function(_0x235ca9){if(_0x235ca9){_0x2f2a0b=_0x235ca9[_0x65c3('0x49')];if(!_0x1f0da[_0x65c3('0x42')][_0x65c3('0x67')](_0x65c3('0x4a'))){_0x370c0f['limit']=qs[_0x65c3('0x4b')](_0x1f0da[_0x65c3('0x42')][_0x65c3('0x4b')]);_0x370c0f[_0x65c3('0x31')]=qs[_0x65c3('0x31')](_0x1f0da['query'][_0x65c3('0x31')]);}return _0x5f02a0['getAgents'](_0x370c0f);}})['then'](function(_0x565054){if(_0x565054){return _0x565054?{'count':_0x2f2a0b,'rows':_0x565054}:null;}})[_0x65c3('0x23')](respondWithResult(_0x5332f6,null))['catch'](handleError(_0x5332f6,null));};exports['send']=function(_0x2cd211,_0xba8fa4,_0x26b39b){var _0x163f9a,_0x221cbc,_0x3f7d86;if(_[_0x65c3('0x78')](_0x2cd211[_0x65c3('0x59')][_0x65c3('0x59')])||_0x2cd211['body'][_0x65c3('0x59')]===''){throw new db['Sequelize'][(_0x65c3('0x20'))](_0x65c3('0xb3'));}if(_[_0x65c3('0x78')](_0x2cd211['body']['to'])){}_0x163f9a=_0x2cd211['body']['to'];return db[_0x65c3('0x3e')][_0x65c3('0x6f')]({'where':{'id':_0x2cd211[_0x65c3('0x56')]['id']}})[_0x65c3('0x23')](handleEntityNotFound(_0xba8fa4,null))['then'](function(_0x3e1619){if(_0x3e1619){return db[_0x65c3('0x3e')][_0x65c3('0x5e')]({'where':{'id':_0x3e1619['id']},'include':[{'model':db[_0x65c3('0x7e')],'as':_0x65c3('0x7f'),'include':[{'model':db['CmContact'],'as':'Contacts','where':{[_0x3e1619[_0x65c3('0x7a')]]:_0x163f9a},'limit':0x1,'order':[[_0x65c3('0x76'),_0x65c3('0xb4')]]}]}]})[_0x65c3('0x23')](handleEntityNotFound(_0xba8fa4,null))[_0x65c3('0x23')](function(_0x43ee30){if(_0x43ee30&&_0x43ee30[_0x65c3('0x7f')]){_0x221cbc=_0x43ee30[_0x65c3('0x37')]({'plain':!![]});if(_0x221cbc[_0x65c3('0x7f')]&&_0x221cbc['List'][_0x65c3('0x80')][_0x65c3('0x49')]){return _0x221cbc[_0x65c3('0x7f')]['Contacts'][0x0];}return db[_0x65c3('0x72')]['create'](_[_0x65c3('0x17')](_0x2cd211['body'],{'firstName':_0x163f9a,[_0x43ee30[_0x65c3('0x7a')]]:_0x163f9a,'phone':_0x163f9a,'ListId':_0x221cbc[_0x65c3('0x89')]}));}})[_0x65c3('0x23')](handleEntityNotFound(_0xba8fa4,null))[_0x65c3('0x23')](function(_0xa48542){if(_0xa48542){_0x3f7d86=_0xa48542;return db[_0x65c3('0x8d')][_0x65c3('0x5e')]({'where':{'ContactId':_0x3f7d86['id'],'closed':![],'OpenchannelAccountId':_0x221cbc['id']}})[_0x65c3('0x23')](function(_0x2de7d6){if(_0x2de7d6){return[_0x2de7d6,![]];}return db[_0x65c3('0x8d')][_0x65c3('0x58')]({'UserId':_0x2cd211['user']['id'],'ContactId':_0x3f7d86['id'],'OpenchannelAccountId':_0x221cbc['id'],'lastMsgDirection':_0x65c3('0xb5'),'Messages':[_[_0x65c3('0x4f')](_0x2cd211[_0x65c3('0x59')],{'read':![],'body':_0x2cd211[_0x65c3('0x59')][_0x65c3('0x59')],'OpenchannelAccountId':_0x221cbc['id'],'UserId':_0x2cd211['user']['id'],'ContactId':_0x3f7d86['id']})]},{'include':[{'model':db[_0x65c3('0xb6')],'as':_0x65c3('0xb7')}]})[_0x65c3('0x23')](function(_0x2704fc){return[_0x2704fc,!![]];});});}})[_0x65c3('0x90')](function(_0xf9aa50,_0x4c5e8b){if(_0x4c5e8b){return _0xf9aa50;}return db[_0x65c3('0xb6')][_0x65c3('0x58')](_['merge'](_0x2cd211['body'],{'read':![],'body':_0x2cd211['body'][_0x65c3('0x59')],'OpenchannelAccountId':_0x221cbc['id'],'OpenchannelInteractionId':_0xf9aa50['id'],'UserId':_0x2cd211[_0x65c3('0x5a')]['id'],'ContactId':_0x3f7d86['id']}))[_0x65c3('0x23')](function(_0x3cb871){_0xf9aa50[_0x65c3('0xb8')]['Messages']=[];_0xf9aa50[_0x65c3('0xb8')][_0x65c3('0xb7')]['push'](_0x3cb871[_0x65c3('0xb8')]);return _0xf9aa50;});});}})['then'](respondWithResult(_0xba8fa4,null))[_0x65c3('0x2c')](handleError(_0xba8fa4,null));};
\ No newline at end of file
+var _0x1d7b=['dataValues','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','sox','lodash','crypto','desk.js','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelAccount.socket','register','jayson/promise','client','http','request','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','end','status','json','count','offset','limit','Content-Range','apply','reject','save','update','then','destroy','get','OpenchannelAccounts','UserProfileResource','name','send','Pause','mandatoryDispositionPause','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','OpenchannelAccount','includeAll','include','findAll','rows','catch','show','find','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','addDisposition','OpenchannelAccountId','Disposition','getDispositions','findOne','pick','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','options','removeAnswers','notify','openchannel','CmContact','Sequelize','ValidationError','difference','CompanyId','ListId','isNil','from','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','CmList','List','Contacts','updatedAt','DESC','OpenchannelApplication','Applications','applications','list','priority','asc','account','contact','lastName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','firstName','messageId','interaction','created','autoclose','close','*,*,*,*','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','addApplications','transaction','bulkCreate','getApplications','Contact','Owner','fullname','internal','Tag','color','tag','addAgents','emit','userOpenchannelAccount:save','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','body\x20is\x20mandatory\x20and\x20not\x20empty','OpenchannelMessage','Messages'];(function(_0x53be08,_0x4b4609){var _0xe0a29c=function(_0x4b5095){while(--_0x4b5095){_0x53be08['push'](_0x53be08['shift']());}};_0xe0a29c(++_0x4b4609);}(_0x1d7b,0xb9));var _0xb1d7=function(_0x8f45e5,_0x4e1695){_0x8f45e5=_0x8f45e5-0x0;var _0x57c49e=_0x1d7b[_0x8f45e5];return _0x57c49e;};'use strict';var pdf=require(_0xb1d7('0x0'));var emlformat=require(_0xb1d7('0x1'));var rimraf=require(_0xb1d7('0x2'));var zipdir=require(_0xb1d7('0x3'));var jsonpatch=require(_0xb1d7('0x4'));var rp=require(_0xb1d7('0x5'));var moment=require(_0xb1d7('0x6'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xb1d7('0x7'));var path=require(_0xb1d7('0x8'));var sox=require(_0xb1d7('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xb1d7('0xa'));var squel=require('squel');var crypto=require(_0xb1d7('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xb1d7('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xb1d7('0xd'));var qs=require(_0xb1d7('0xe'));var as=require(_0xb1d7('0xf'));var hardwareService=require(_0xb1d7('0x10'));var logger=require(_0xb1d7('0x11'))(_0xb1d7('0x12'));var utils=require('../../config/utils');var config=require(_0xb1d7('0x13'));var licenseUtil=require(_0xb1d7('0x14'));var db=require(_0xb1d7('0x15'))['db'];config[_0xb1d7('0x16')]=_[_0xb1d7('0x17')](config[_0xb1d7('0x16')],{'host':_0xb1d7('0x18'),'port':0x18eb});var socket=require(_0xb1d7('0x19'))(new Redis(config['redis']));require(_0xb1d7('0x1a'))[_0xb1d7('0x1b')](socket);var jayson=require(_0xb1d7('0x1c'));var client=jayson[_0xb1d7('0x1d')][_0xb1d7('0x1e')]({'port':0x232c});var client9002=jayson[_0xb1d7('0x1d')]['http']({'port':0x232a});function respondWithRpcPromise(_0x458350,_0x2e2bdc,_0x368de9,_0x28068c){return new BPromise(function(_0x3cd53c,_0xad2b82){var _0x354440=_0x28068c||client;return _0x354440[_0xb1d7('0x1f')](_0x458350,_0x368de9)['then'](function(_0x17cce2){logger['info'](_0xb1d7('0x20'),_0x2e2bdc,_0xb1d7('0x21'));logger[_0xb1d7('0x22')](_0xb1d7('0x23'),_0x2e2bdc,'request\x20sent',JSON[_0xb1d7('0x24')](_0x17cce2));if(_0x17cce2[_0xb1d7('0x25')]){if(_0x17cce2[_0xb1d7('0x25')][_0xb1d7('0x26')]===0x1f4){logger[_0xb1d7('0x25')](_0xb1d7('0x20'),_0x2e2bdc,_0x17cce2[_0xb1d7('0x25')][_0xb1d7('0x27')]);return _0xad2b82(_0x17cce2[_0xb1d7('0x25')]['message']);}logger[_0xb1d7('0x25')](_0xb1d7('0x20'),_0x2e2bdc,_0x17cce2[_0xb1d7('0x25')][_0xb1d7('0x27')]);return _0x3cd53c(_0x17cce2[_0xb1d7('0x25')][_0xb1d7('0x27')]);}else{logger[_0xb1d7('0x28')]('OpenchannelAccount,\x20%s,\x20%s',_0x2e2bdc,'request\x20sent');_0x3cd53c(_0x17cce2['result'][_0xb1d7('0x27')]);}})['catch'](function(_0x2689f4){logger[_0xb1d7('0x25')]('OpenchannelAccount,\x20%s,\x20%s',_0x2e2bdc,_0x2689f4);_0xad2b82(_0x2689f4);});});}function respondWithStatusCode(_0x1a6168,_0x526cd4){_0x526cd4=_0x526cd4||0xcc;return function(_0xb5cc7b){if(_0xb5cc7b){return _0x1a6168['sendStatus'](_0x526cd4);}return _0x1a6168['status'](_0x526cd4)[_0xb1d7('0x29')]();};}function respondWithResult(_0x11dc04,_0x145dd7){_0x145dd7=_0x145dd7||0xc8;return function(_0x57e8f2){if(_0x57e8f2){return _0x11dc04[_0xb1d7('0x2a')](_0x145dd7)[_0xb1d7('0x2b')](_0x57e8f2);}};}function respondWithFilteredResult(_0x9b9d7,_0x57768f){return function(_0x389e81){if(_0x389e81){var _0x1941be=_0x389e81[_0xb1d7('0x2c')],_0x28508f=_0x57768f[_0xb1d7('0x2d')],_0x423a68=_0x57768f[_0xb1d7('0x2d')]+_0x57768f[_0xb1d7('0x2e')],_0x1cf760;if(_0x423a68>=_0x1941be){_0x423a68=_0x1941be;_0x1cf760=0xc8;}else{_0x1cf760=0xce;}_0x9b9d7[_0xb1d7('0x2a')](_0x1cf760);return _0x9b9d7['set'](_0xb1d7('0x2f'),_0x28508f+'-'+_0x423a68+'/'+_0x1941be)['json'](_0x389e81);}return null;};}function patchUpdates(_0x2bd3cb){return function(_0x1101a5){try{jsonpatch[_0xb1d7('0x30')](_0x1101a5,_0x2bd3cb,!![]);}catch(_0x4a8254){return BPromise[_0xb1d7('0x31')](_0x4a8254);}return _0x1101a5[_0xb1d7('0x32')]();};}function saveUpdates(_0x53eec2,_0x4955a3){return function(_0x38d9e3){if(_0x38d9e3){return _0x38d9e3[_0xb1d7('0x33')](_0x53eec2)[_0xb1d7('0x34')](function(_0x5c81ae){return _0x5c81ae;});}return null;};}function removeEntity(_0x540e60,_0x5c4076){return function(_0xc54708){if(_0xc54708){return _0xc54708[_0xb1d7('0x35')]()['then'](function(){var _0x1e231b=_0xc54708[_0xb1d7('0x36')]({'plain':!![]});var _0x4bd02f=_0xb1d7('0x37');return db[_0xb1d7('0x38')][_0xb1d7('0x35')]({'where':{'type':_0x4bd02f,'resourceId':_0x1e231b['id']}})[_0xb1d7('0x34')](function(){return _0xc54708;});})[_0xb1d7('0x34')](function(){_0x540e60['status'](0xcc)[_0xb1d7('0x29')]();});}};}function handleEntityNotFound(_0x341d74,_0x566acd){return function(_0x2d14f8){if(!_0x2d14f8){_0x341d74['sendStatus'](0x194);}return _0x2d14f8;};}function handleError(_0x7e7c57,_0x4d1e0b){_0x4d1e0b=_0x4d1e0b||0x1f4;return function(_0x1acf9e){logger['error'](_0x1acf9e['stack']);if(_0x1acf9e[_0xb1d7('0x39')]){delete _0x1acf9e[_0xb1d7('0x39')];}_0x7e7c57[_0xb1d7('0x2a')](_0x4d1e0b)[_0xb1d7('0x3a')](_0x1acf9e);};}exports['index']=function(_0x39ce8c,_0x6e9f50){var _0x2f2ead={'include':[{'model':db[_0xb1d7('0x3b')],'as':_0xb1d7('0x3c')}]},_0x8ca49b={},_0xff4ff3={'count':0x0,'rows':[]};var _0x3adef9=_[_0xb1d7('0x3d')](db['OpenchannelAccount'][_0xb1d7('0x3e')],function(_0x18ad98){return{'name':_0x18ad98[_0xb1d7('0x3f')],'type':_0x18ad98[_0xb1d7('0x40')][_0xb1d7('0x41')]};});_0x8ca49b[_0xb1d7('0x42')]=_[_0xb1d7('0x3d')](_0x3adef9,'name');_0x8ca49b[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x39ce8c[_0xb1d7('0x43')]);_0x8ca49b[_0xb1d7('0x45')]=_[_0xb1d7('0x46')](_0x8ca49b[_0xb1d7('0x42')],_0x8ca49b['query']);_0x2f2ead[_0xb1d7('0x47')]=_[_0xb1d7('0x46')](_0x8ca49b[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x2f2ead[_0xb1d7('0x47')]=_0x2f2ead['attributes'][_0xb1d7('0x49')]?_0x2f2ead[_0xb1d7('0x47')]:_0x8ca49b[_0xb1d7('0x42')];if(!_0x39ce8c['query'][_0xb1d7('0x4a')](_0xb1d7('0x4b'))){_0x2f2ead[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x2e')]);_0x2f2ead['offset']=qs[_0xb1d7('0x2d')](_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x2d')]);}_0x2f2ead[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x2f2ead[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_['pick'](_0x39ce8c[_0xb1d7('0x43')],_0x8ca49b[_0xb1d7('0x45')]),_0x3adef9);if(_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x4f')]){_0x2f2ead[_0xb1d7('0x4e')]=_[_0xb1d7('0x50')](_0x2f2ead[_0xb1d7('0x4e')],{'$or':_[_0xb1d7('0x3d')](_0x3adef9,function(_0x46caa5){if(_0x46caa5['type']!==_0xb1d7('0x51')){var _0xb37874={};_0xb37874[_0x46caa5[_0xb1d7('0x39')]]={'$like':'%'+_0x39ce8c['query']['filter']+'%'};return _0xb37874;}})});}_0x2f2ead=_['merge']({},_0x2f2ead,_0x39ce8c['options']);var _0x26b902={'where':_0x2f2ead[_0xb1d7('0x4e')]};return db[_0xb1d7('0x52')][_0xb1d7('0x2c')](_0x26b902)[_0xb1d7('0x34')](function(_0x4dba54){_0xff4ff3[_0xb1d7('0x2c')]=_0x4dba54;if(_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x53')]){_0x2f2ead[_0xb1d7('0x54')]=[{'all':!![]}];}return db[_0xb1d7('0x52')][_0xb1d7('0x55')](_0x2f2ead);})[_0xb1d7('0x34')](function(_0x569710){_0xff4ff3[_0xb1d7('0x56')]=_0x569710;return _0xff4ff3;})[_0xb1d7('0x34')](respondWithFilteredResult(_0x6e9f50,_0x2f2ead))[_0xb1d7('0x57')](handleError(_0x6e9f50,null));};exports[_0xb1d7('0x58')]=function(_0x397d2a,_0x2ed495){var _0x4a7b23={'raw':![],'where':{'id':_0x397d2a['params']['id']},'include':[{'model':db[_0xb1d7('0x3b')],'as':_0xb1d7('0x3c')}]},_0x586814={};_0x586814['model']=_[_0xb1d7('0x44')](db[_0xb1d7('0x52')][_0xb1d7('0x3e')]);_0x586814[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x397d2a['query']);_0x586814['filters']=_[_0xb1d7('0x46')](_0x586814[_0xb1d7('0x42')],_0x586814[_0xb1d7('0x43')]);_0x4a7b23['attributes']=_['intersection'](_0x586814[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x397d2a[_0xb1d7('0x43')]['fields']));_0x4a7b23[_0xb1d7('0x47')]=_0x4a7b23[_0xb1d7('0x47')]['length']?_0x4a7b23[_0xb1d7('0x47')]:_0x586814[_0xb1d7('0x42')];if(_0x397d2a[_0xb1d7('0x43')]['includeAll']){_0x4a7b23[_0xb1d7('0x54')]=[{'all':!![]}];}_0x4a7b23=_[_0xb1d7('0x50')]({},_0x4a7b23,_0x397d2a['options']);return db['OpenchannelAccount'][_0xb1d7('0x59')](_0x4a7b23)[_0xb1d7('0x34')](handleEntityNotFound(_0x2ed495,null))[_0xb1d7('0x34')](respondWithResult(_0x2ed495,null))[_0xb1d7('0x57')](handleError(_0x2ed495,null));};exports['create']=function(_0x4ee3b3,_0x3700d5){return db[_0xb1d7('0x52')]['create'](_0x4ee3b3['body'],{})[_0xb1d7('0x34')](function(_0x123689){var _0x307965=_0x4ee3b3[_0xb1d7('0x5a')][_0xb1d7('0x36')]({'plain':!![]});if(!_0x307965)throw new Error(_0xb1d7('0x5b'));if(_0x307965[_0xb1d7('0x5c')]===_0xb1d7('0x5a')){var _0xf9cc07=_0x123689[_0xb1d7('0x36')]({'plain':!![]});var _0x44b52e=_0xb1d7('0x37');return db[_0xb1d7('0x5d')][_0xb1d7('0x59')]({'where':{'name':_0x44b52e,'userProfileId':_0x307965['userProfileId']},'raw':!![]})[_0xb1d7('0x34')](function(_0x12c8f5){if(_0x12c8f5&&_0x12c8f5[_0xb1d7('0x5e')]===0x0){return db[_0xb1d7('0x38')][_0xb1d7('0x5f')]({'name':_0xf9cc07[_0xb1d7('0x39')],'resourceId':_0xf9cc07['id'],'type':_0x12c8f5[_0xb1d7('0x39')],'sectionId':_0x12c8f5['id']},{})['then'](function(){return _0x123689;});}else{return _0x123689;}})[_0xb1d7('0x57')](function(_0x50921d){logger[_0xb1d7('0x25')](_0xb1d7('0x60'),_0x50921d);throw _0x50921d;});}return _0x123689;})['then'](respondWithResult(_0x3700d5,0xc9))[_0xb1d7('0x57')](handleError(_0x3700d5,null));};exports[_0xb1d7('0x33')]=function(_0x4b6b62,_0x573af7){if(_0x4b6b62[_0xb1d7('0x61')]['id']){delete _0x4b6b62[_0xb1d7('0x61')]['id'];}return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x4b6b62[_0xb1d7('0x62')]['id']},'include':[{'model':db[_0xb1d7('0x3b')],'as':_0xb1d7('0x3c')}]})[_0xb1d7('0x34')](handleEntityNotFound(_0x573af7,null))[_0xb1d7('0x34')](saveUpdates(_0x4b6b62[_0xb1d7('0x61')],null))['then'](respondWithResult(_0x573af7,null))[_0xb1d7('0x57')](handleError(_0x573af7,null));};exports['destroy']=function(_0x44c1b3,_0x56159f){return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x44c1b3[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x56159f,null))[_0xb1d7('0x34')](removeEntity(_0x56159f,null))['catch'](handleError(_0x56159f,null));};exports[_0xb1d7('0x63')]=function(_0x32a2ed,_0xf559b4){return db[_0xb1d7('0x52')][_0xb1d7('0x63')]()[_0xb1d7('0x34')](respondWithResult(_0xf559b4,null))[_0xb1d7('0x57')](handleError(_0xf559b4,null));};exports[_0xb1d7('0x64')]=function(_0x144105,_0x327c00,_0x1a0f28){if(_0x144105['body']['id']){delete _0x144105[_0xb1d7('0x61')]['id'];}return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x144105[_0xb1d7('0x62')]['id']}})['then'](handleEntityNotFound(_0x327c00,null))[_0xb1d7('0x34')](function(_0x64c455){if(_0x64c455){_0x144105[_0xb1d7('0x61')][_0xb1d7('0x65')]=_0x64c455['id'];return db[_0xb1d7('0x66')]['create'](_0x144105[_0xb1d7('0x61')]);}})[_0xb1d7('0x34')](respondWithResult(_0x327c00,null))[_0xb1d7('0x57')](handleError(_0x327c00,null));};exports[_0xb1d7('0x67')]=function(_0x443047,_0x2fd556,_0x34f5a5){var _0x555a85={'raw':![],'where':{}};var _0x3c7470={};var _0x258066={'count':0x0,'rows':[]};return db[_0xb1d7('0x52')][_0xb1d7('0x68')]({'where':{'id':_0x443047[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x2fd556,null))[_0xb1d7('0x34')](function(_0x3ba299){if(_0x3ba299){_0x3c7470['model']=_[_0xb1d7('0x44')](db[_0xb1d7('0x66')]['rawAttributes']);_0x3c7470['query']=_[_0xb1d7('0x44')](_0x443047[_0xb1d7('0x43')]);_0x3c7470['filters']=_[_0xb1d7('0x46')](_0x3c7470[_0xb1d7('0x42')],_0x3c7470[_0xb1d7('0x43')]);_0x555a85[_0xb1d7('0x47')]=_['intersection'](_0x3c7470[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x443047[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x555a85[_0xb1d7('0x47')]=_0x555a85['attributes'][_0xb1d7('0x49')]?_0x555a85[_0xb1d7('0x47')]:_0x3c7470['model'];if(!_0x443047[_0xb1d7('0x43')][_0xb1d7('0x4a')](_0xb1d7('0x4b'))){_0x555a85[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x443047[_0xb1d7('0x43')][_0xb1d7('0x2e')]);_0x555a85[_0xb1d7('0x2d')]=qs[_0xb1d7('0x2d')](_0x443047['query'][_0xb1d7('0x2d')]);}_0x555a85[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x443047[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x555a85[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_[_0xb1d7('0x69')](_0x443047[_0xb1d7('0x43')],_0x3c7470[_0xb1d7('0x45')]));_0x555a85[_0xb1d7('0x4e')][_0xb1d7('0x65')]=_0x3ba299['id'];if(_0x443047[_0xb1d7('0x43')][_0xb1d7('0x4f')]){_0x555a85['where']=_[_0xb1d7('0x50')](_0x555a85[_0xb1d7('0x4e')],{'$or':_[_0xb1d7('0x3d')](_0x555a85[_0xb1d7('0x47')],function(_0x5940cd){var _0xd900aa={};_0xd900aa[_0x5940cd]={'$like':'%'+_0x443047[_0xb1d7('0x43')]['filter']+'%'};return _0xd900aa;})});}_0x555a85=_[_0xb1d7('0x50')]({},_0x555a85,_0x443047['options']);return db[_0xb1d7('0x66')][_0xb1d7('0x2c')]({'where':_0x555a85['where']})[_0xb1d7('0x34')](function(_0x1c11d3){_0x258066[_0xb1d7('0x2c')]=_0x1c11d3;if(_0x443047[_0xb1d7('0x43')][_0xb1d7('0x53')]){_0x555a85[_0xb1d7('0x54')]=[{'all':!![]}];}return db[_0xb1d7('0x66')][_0xb1d7('0x55')](_0x555a85);})[_0xb1d7('0x34')](function(_0xa9dbd){_0x258066[_0xb1d7('0x56')]=_0xa9dbd;return _0x258066;});}})[_0xb1d7('0x34')](respondWithFilteredResult(_0x2fd556,_0x555a85))[_0xb1d7('0x57')](handleError(_0x2fd556,null));};exports[_0xb1d7('0x6a')]=function(_0x348a7c,_0x4172af,_0x41cd15){return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x348a7c[_0xb1d7('0x62')]['id']}})['then'](handleEntityNotFound(_0x4172af,null))['then'](function(_0x1487da){if(_0x1487da){return _0x1487da[_0xb1d7('0x6a')](_0x348a7c[_0xb1d7('0x43')][_0xb1d7('0x6b')]);}})[_0xb1d7('0x34')](respondWithStatusCode(_0x4172af,null))[_0xb1d7('0x57')](handleError(_0x4172af,null));};exports[_0xb1d7('0x6c')]=function(_0x8f95da,_0x25e774,_0x187e60){if(_0x8f95da[_0xb1d7('0x61')]['id']){delete _0x8f95da['body']['id'];}return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x8f95da['params']['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x25e774,null))[_0xb1d7('0x34')](function(_0x3892c7){if(_0x3892c7){_0x8f95da[_0xb1d7('0x61')][_0xb1d7('0x65')]=_0x3892c7['id'];return db[_0xb1d7('0x6d')][_0xb1d7('0x5f')](_0x8f95da[_0xb1d7('0x61')]);}})['then'](respondWithResult(_0x25e774,null))[_0xb1d7('0x57')](handleError(_0x25e774,null));};exports[_0xb1d7('0x6e')]=function(_0x5e2974,_0x5e3a83,_0x276431){var _0x2c19d7={'raw':![],'where':{}};var _0x3d72fd={};var _0x328c24={'count':0x0,'rows':[]};return db[_0xb1d7('0x52')][_0xb1d7('0x68')]({'where':{'id':_0x5e2974[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x5e3a83,null))[_0xb1d7('0x34')](function(_0x533bac){if(_0x533bac){_0x3d72fd[_0xb1d7('0x42')]=_[_0xb1d7('0x44')](db['CannedAnswer'][_0xb1d7('0x3e')]);_0x3d72fd[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x5e2974[_0xb1d7('0x43')]);_0x3d72fd['filters']=_[_0xb1d7('0x46')](_0x3d72fd[_0xb1d7('0x42')],_0x3d72fd[_0xb1d7('0x43')]);_0x2c19d7[_0xb1d7('0x47')]=_[_0xb1d7('0x46')](_0x3d72fd[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x2c19d7[_0xb1d7('0x47')]=_0x2c19d7[_0xb1d7('0x47')][_0xb1d7('0x49')]?_0x2c19d7[_0xb1d7('0x47')]:_0x3d72fd[_0xb1d7('0x42')];if(!_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x4a')](_0xb1d7('0x4b'))){_0x2c19d7[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x2e')]);_0x2c19d7[_0xb1d7('0x2d')]=qs[_0xb1d7('0x2d')](_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x2d')]);}_0x2c19d7[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x2c19d7[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_['pick'](_0x5e2974['query'],_0x3d72fd[_0xb1d7('0x45')]));_0x2c19d7[_0xb1d7('0x4e')][_0xb1d7('0x65')]=_0x533bac['id'];if(_0x5e2974[_0xb1d7('0x43')]['filter']){_0x2c19d7['where']=_['merge'](_0x2c19d7[_0xb1d7('0x4e')],{'$or':_['map'](_0x2c19d7[_0xb1d7('0x47')],function(_0xa743a5){var _0x1a69c4={};_0x1a69c4[_0xa743a5]={'$like':'%'+_0x5e2974[_0xb1d7('0x43')]['filter']+'%'};return _0x1a69c4;})});}_0x2c19d7=_[_0xb1d7('0x50')]({},_0x2c19d7,_0x5e2974[_0xb1d7('0x6f')]);return db[_0xb1d7('0x6d')][_0xb1d7('0x2c')]({'where':_0x2c19d7[_0xb1d7('0x4e')]})[_0xb1d7('0x34')](function(_0x5868cc){_0x328c24[_0xb1d7('0x2c')]=_0x5868cc;if(_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x53')]){_0x2c19d7[_0xb1d7('0x54')]=[{'all':!![]}];}return db[_0xb1d7('0x6d')][_0xb1d7('0x55')](_0x2c19d7);})[_0xb1d7('0x34')](function(_0x2689a9){_0x328c24[_0xb1d7('0x56')]=_0x2689a9;return _0x328c24;});}})['then'](respondWithFilteredResult(_0x5e3a83,_0x2c19d7))[_0xb1d7('0x57')](handleError(_0x5e3a83,null));};exports[_0xb1d7('0x70')]=function(_0x1e4b3f,_0x2a8817,_0x93c8df){return db['OpenchannelAccount'][_0xb1d7('0x59')]({'where':{'id':_0x1e4b3f[_0xb1d7('0x62')]['id']}})['then'](handleEntityNotFound(_0x2a8817,null))[_0xb1d7('0x34')](function(_0x51e3f4){if(_0x51e3f4){return _0x51e3f4['removeAnswers'](_0x1e4b3f[_0xb1d7('0x43')]['ids']);}})[_0xb1d7('0x34')](respondWithStatusCode(_0x2a8817,null))[_0xb1d7('0x57')](handleError(_0x2a8817,null));};exports[_0xb1d7('0x71')]=function(_0x517121,_0x249300,_0x411f3d){var _0x14a111={'body':_0x517121[_0xb1d7('0x61')],'channel':_0xb1d7('0x72')};var _0x19e86e=[];var _0x3cb71d=[];var _0x33ddc0={};var _0x293c60=![];return db[_0xb1d7('0x73')][_0xb1d7('0x63')]()[_0xb1d7('0x34')](function(_0x8b6a64){if(!_0x8b6a64){throw new db[(_0xb1d7('0x74'))][(_0xb1d7('0x75'))]('no\x20available\x20attributes');}_0x19e86e=_['difference'](_[_0xb1d7('0x44')](_0x8b6a64),['createdAt','updatedAt']);_0x3cb71d=_[_0xb1d7('0x76')](_['keys'](_0x8b6a64),['createdAt','updatedAt',_0xb1d7('0x77'),_0xb1d7('0x78')]);if(_0x517121[_0xb1d7('0x61')]['id']){delete _0x517121[_0xb1d7('0x61')]['id'];}if(_[_0xb1d7('0x79')](_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7a')])){throw new db[(_0xb1d7('0x74'))][(_0xb1d7('0x75'))]('from\x20is\x20mandatory');}if(_[_0xb1d7('0x79')](_0x517121[_0xb1d7('0x61')]['body'])||_0x517121[_0xb1d7('0x61')][_0xb1d7('0x61')]===''){throw new db[(_0xb1d7('0x74'))][(_0xb1d7('0x75'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xb1d7('0x79')](_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7b')])){throw new db[(_0xb1d7('0x74'))][(_0xb1d7('0x75'))](_0xb1d7('0x7c')+_0x3cb71d);}if(!_[_0xb1d7('0x7d')](_0x3cb71d,_0x517121[_0xb1d7('0x61')]['mapKey'])){throw new db['Sequelize'][(_0xb1d7('0x75'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x3cb71d);}_0x33ddc0[_0x517121['body'][_0xb1d7('0x7b')]]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7a')];})[_0xb1d7('0x34')](function(){return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x517121['params']['id']},'include':[{'model':db[_0xb1d7('0x7e')],'as':_0xb1d7('0x7f'),'include':[{'model':db['CmContact'],'as':_0xb1d7('0x80'),'where':_0x33ddc0,'limit':0x1,'order':[[_0xb1d7('0x81'),_0xb1d7('0x82')]]}]},{'model':db[_0xb1d7('0x83')],'as':_0xb1d7('0x84')}]});})[_0xb1d7('0x34')](handleEntityNotFound(_0x249300,null))[_0xb1d7('0x34')](function(_0x48cf3f){if(_0x48cf3f&&_0x48cf3f[_0xb1d7('0x7f')]){_0x14a111['account']=_0x48cf3f;_0x14a111[_0xb1d7('0x85')]=_0x48cf3f[_0xb1d7('0x84')];_0x14a111[_0xb1d7('0x86')]=_0x48cf3f[_0xb1d7('0x7f')];_0x14a111['applications']=_['orderBy'](_0x14a111[_0xb1d7('0x85')],[_0xb1d7('0x87')],[_0xb1d7('0x88')]);if(_0x14a111[_0xb1d7('0x89')][_0xb1d7('0x84')]){delete _0x14a111['account'][_0xb1d7('0x84')];}if(_0x14a111[_0xb1d7('0x89')][_0xb1d7('0x7f')]&&_0x14a111[_0xb1d7('0x89')]['List'][_0xb1d7('0x80')]['length']){return _0x14a111['account']['List'][_0xb1d7('0x80')][0x0];}var _0x2c2784=_['defaults'](_0x517121[_0xb1d7('0x61')],{'firstName':_0x517121['body'][_0xb1d7('0x7a')],'ListId':_0x48cf3f[_0xb1d7('0x78')]});_0x2c2784[_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7b')]]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7a')];return db[_0xb1d7('0x73')][_0xb1d7('0x5f')](_0x2c2784,{'fields':_0x19e86e,'raw':!![]});}})[_0xb1d7('0x34')](handleEntityNotFound(_0x249300,null))[_0xb1d7('0x34')](function(_0x478021){_0x14a111[_0xb1d7('0x8a')]=_0x478021;if(_0x478021){var _0x34bbe9={'ContactId':_0x478021['id'],'OpenchannelAccountId':_0x517121[_0xb1d7('0x62')]['id'],'from':(_0x478021['firstName']||'')+'\x20'+(_0x478021[_0xb1d7('0x8b')]||'')};var _0x505af0={'OpenchannelAccountId':_0x517121[_0xb1d7('0x62')]['id'],'closed':![]};if(_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8c')]){_0x505af0[_0xb1d7('0x8c')]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8c')];return db[_0xb1d7('0x8d')][_0xb1d7('0x59')]({'where':_0x505af0})[_0xb1d7('0x34')](function(_0x38ffdd){if(_0x38ffdd){return[_0x38ffdd,![]];}_0x34bbe9[_0xb1d7('0x8c')]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8c')];_0x34bbe9[_0xb1d7('0x8e')]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8e')];return db[_0xb1d7('0x8d')][_0xb1d7('0x5f')](_0x34bbe9)[_0xb1d7('0x34')](function(_0x43ad06){return[_0x43ad06,!![]];});});}else{_0x505af0[_0xb1d7('0x8c')]=null;}_0x505af0[_0xb1d7('0x8f')]=_0x478021['id'];return db[_0xb1d7('0x8d')][_0xb1d7('0x59')]({'where':_0x505af0})['then'](function(_0x590d15){if(_0x590d15){return[_0x590d15,![]];}return db[_0xb1d7('0x8d')][_0xb1d7('0x5f')](_0x34bbe9)[_0xb1d7('0x34')](function(_0x4a01b7){return[_0x4a01b7,!![]];});});}})[_0xb1d7('0x90')](function(_0x39929a,_0x4252cd){if(_0x39929a){_0x293c60=_0x4252cd;if(!_0x4252cd){var _0x25db1d={'from':(_0x14a111['contact'][_0xb1d7('0x91')]||'')+'\x20'+(_0x14a111[_0xb1d7('0x8a')][_0xb1d7('0x8b')]||'')};if(_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8c')]&&_0x517121['body'][_0xb1d7('0x92')]&&_0x517121[_0xb1d7('0x61')]['threadId']!=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x92')]){_0x25db1d[_0xb1d7('0x8c')]=_0x517121['body']['messageId'];}return _0x39929a[_0xb1d7('0x33')](_0x25db1d);}else{return _0x39929a;}}})[_0xb1d7('0x34')](function(_0x47335f){_0x14a111[_0xb1d7('0x93')]=_0x47335f['get']({'plain':!![]});_0x14a111['interaction'][_0xb1d7('0x94')]=_0x293c60;if(_0x14a111['interaction'][_0xb1d7('0x94')]){if(_0x14a111[_0xb1d7('0x89')][_0xb1d7('0x95')]){_0x14a111[_0xb1d7('0x85')]['push']({'id':0x0,'priority':_0x14a111[_0xb1d7('0x85')][_0xb1d7('0x49')]+0x1,'app':_0xb1d7('0x96'),'appdata':'unmanaged','interval':_0xb1d7('0x97')});}}return db['OpenchannelMessage']['create']({'body':_0x517121[_0xb1d7('0x61')][_0xb1d7('0x61')],'OpenchannelAccountId':_0x517121[_0xb1d7('0x62')]['id'],'OpenchannelInteractionId':_0x47335f['id'],'direction':'in','ContactId':_0x14a111[_0xb1d7('0x8a')]['id'],'AttachmentId':_0x517121[_0xb1d7('0x61')][_0xb1d7('0x98')]});})[_0xb1d7('0x34')](function(_0x4c8219){_0x14a111['message']=_0x4c8219;if(_0x14a111['interaction'][_0xb1d7('0x99')]){return db[_0xb1d7('0x9a')]['find']({'attributes':['id',_0xb1d7('0x39')],'where':{'id':_0x14a111['interaction'][_0xb1d7('0x99')]}})['then'](function(_0x5941d0){if(_0x5941d0){_0x14a111[_0xb1d7('0x85')][_0xb1d7('0x9b')]({'id':0x0,'priority':0x0,'app':_0xb1d7('0x9c'),'appdata':_0x5941d0['name']+','+(_0x14a111[_0xb1d7('0x89')][_0xb1d7('0x9d')]||0xa),'interval':_0xb1d7('0x97')});_0x14a111[_0xb1d7('0x9e')]=![];}return respondWithRpcPromise(_0xb1d7('0x9f'),'startRouting',_0x14a111);});}return respondWithRpcPromise(_0xb1d7('0x9f'),_0xb1d7('0xa0'),_0x14a111);})['then'](function(_0x3482c1){respondWithRpcPromise(_0xb1d7('0xa1'),_0xb1d7('0xa1'),{'event':_0xb1d7('0x71'),'message':_0x3482c1},client9002);return _0x3482c1;})[_0xb1d7('0x34')](respondWithResult(_0x249300,null))[_0xb1d7('0x57')](handleError(_0x249300,null));};exports[_0xb1d7('0xa2')]=function(_0x253bca,_0x5624db,_0x3846a4){return db[_0xb1d7('0x52')][_0xb1d7('0x68')]({'where':{'id':_0x253bca[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x5624db,null))[_0xb1d7('0x34')](function(_0x4724ad){if(_0x4724ad){return db['sequelize'][_0xb1d7('0xa3')](function(_0x1821c5){return db['OpenchannelApplication'][_0xb1d7('0x35')]({'where':{'OpenchannelAccountId':_0x253bca[_0xb1d7('0x62')]['id']},'transaction':_0x1821c5})[_0xb1d7('0x34')](function(_0x5375c1){var _0x3c0ede=_[_0xb1d7('0x3d')](_0x253bca[_0xb1d7('0x61')],function(_0x4f2a76){_0x4f2a76[_0xb1d7('0x65')]=_0x253bca[_0xb1d7('0x62')]['id'];return _0x4f2a76;});return db['OpenchannelApplication'][_0xb1d7('0xa4')](_0x3c0ede,{'transaction':_0x1821c5});});})[_0xb1d7('0x34')](function(){return db[_0xb1d7('0x83')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0x253bca[_0xb1d7('0x62')]['id']},'order':_0xb1d7('0x87')});});}})['then'](respondWithResult(_0x5624db,null))[_0xb1d7('0x57')](handleError(_0x5624db,null));};exports[_0xb1d7('0xa5')]=function(_0x31f843,_0x37e3ae,_0x47188d){var _0x589fff={};var _0x3b5fec={};var _0x274099;var _0x4e1ca2;return db['OpenchannelAccount'][_0xb1d7('0x68')]({'where':{'id':_0x31f843[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x37e3ae,null))['then'](function(_0x3e313f){if(_0x3e313f){_0x274099=_0x3e313f;_0x3b5fec[_0xb1d7('0x42')]=_[_0xb1d7('0x44')](db[_0xb1d7('0x83')][_0xb1d7('0x3e')]);_0x3b5fec[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x31f843['query']);_0x3b5fec['filters']=_[_0xb1d7('0x46')](_0x3b5fec['model'],_0x3b5fec[_0xb1d7('0x43')]);_0x589fff['attributes']=_['intersection'](_0x3b5fec[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x589fff[_0xb1d7('0x47')]=_0x589fff['attributes'][_0xb1d7('0x49')]?_0x589fff[_0xb1d7('0x47')]:_0x3b5fec[_0xb1d7('0x42')];_0x589fff['order']=qs[_0xb1d7('0x4d')](_0x31f843['query'][_0xb1d7('0x4d')]);_0x589fff[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_[_0xb1d7('0x69')](_0x31f843[_0xb1d7('0x43')],_0x3b5fec[_0xb1d7('0x45')]));if(_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x4f')]){_0x589fff['where']=_['merge'](_0x589fff[_0xb1d7('0x4e')],{'$or':_[_0xb1d7('0x3d')](_0x589fff[_0xb1d7('0x47')],function(_0x38c415){var _0x44dedc={};_0x44dedc[_0x38c415]={'$like':'%'+_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x4f')]+'%'};return _0x44dedc;})});}_0x589fff=_[_0xb1d7('0x50')]({},_0x589fff,_0x31f843['options']);return _0x274099[_0xb1d7('0xa5')](_0x589fff);}})[_0xb1d7('0x34')](function(_0x2075a0){if(_0x2075a0){_0x4e1ca2=_0x2075a0['length'];if(!_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x4a')]('nolimit')){_0x589fff[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x2e')]);_0x589fff['offset']=qs[_0xb1d7('0x2d')](_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x2d')]);}return _0x274099[_0xb1d7('0xa5')](_0x589fff);}})['then'](function(_0x1f6be9){if(_0x1f6be9){return _0x1f6be9?{'count':_0x4e1ca2,'rows':_0x1f6be9}:null;}})[_0xb1d7('0x34')](respondWithResult(_0x37e3ae,null))['catch'](handleError(_0x37e3ae,null));};exports['getInteractions']=function(_0x32d0d5,_0x1c1826,_0x1c63e1){var _0x31eb39={'raw':![],'where':{}};var _0x592bdc={};var _0x2b753c={'count':0x0,'rows':[]};return db[_0xb1d7('0x52')][_0xb1d7('0x68')]({'where':{'id':_0x32d0d5[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x1c1826,null))[_0xb1d7('0x34')](function(_0x18931e){if(_0x18931e){_0x592bdc[_0xb1d7('0x42')]=_[_0xb1d7('0x44')](db[_0xb1d7('0x8d')][_0xb1d7('0x3e')]);_0x592bdc[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x32d0d5[_0xb1d7('0x43')]);_0x592bdc[_0xb1d7('0x45')]=_[_0xb1d7('0x46')](_0x592bdc[_0xb1d7('0x42')],_0x592bdc[_0xb1d7('0x43')]);_0x31eb39[_0xb1d7('0x47')]=_[_0xb1d7('0x46')](_0x592bdc[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x31eb39['attributes']=_0x31eb39['attributes'][_0xb1d7('0x49')]?_0x31eb39[_0xb1d7('0x47')]:_0x592bdc['model'];if(!_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x4a')](_0xb1d7('0x4b'))){_0x31eb39[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x32d0d5['query'][_0xb1d7('0x2e')]);_0x31eb39[_0xb1d7('0x2d')]=qs[_0xb1d7('0x2d')](_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x2d')]);}_0x31eb39[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x31eb39[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_[_0xb1d7('0x69')](_0x32d0d5[_0xb1d7('0x43')],_0x592bdc[_0xb1d7('0x45')]));_0x31eb39[_0xb1d7('0x4e')][_0xb1d7('0x65')]=_0x18931e['id'];if(_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x4f')]){_0x31eb39[_0xb1d7('0x4e')]=_[_0xb1d7('0x50')](_0x31eb39['where'],{'$or':_[_0xb1d7('0x3d')](_0x31eb39[_0xb1d7('0x47')],function(_0x49be96){var _0x50378d={};_0x50378d[_0x49be96]={'$like':'%'+_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x4f')]+'%'};return _0x50378d;})});}_0x31eb39=_[_0xb1d7('0x50')]({},_0x31eb39,_0x32d0d5[_0xb1d7('0x6f')]);return db[_0xb1d7('0x8d')]['count']({'where':_0x31eb39[_0xb1d7('0x4e')]})[_0xb1d7('0x34')](function(_0x395b2e){_0x2b753c[_0xb1d7('0x2c')]=_0x395b2e;if(_0x32d0d5[_0xb1d7('0x43')]['includeAll']){_0x31eb39[_0xb1d7('0x54')]=[{'model':db[_0xb1d7('0x73')],'as':_0xb1d7('0xa6'),'required':![]},{'model':db[_0xb1d7('0x9a')],'as':_0xb1d7('0xa7'),'attributes':[_0xb1d7('0x39'),_0xb1d7('0xa8'),_0xb1d7('0xa9')],'required':![]},{'model':db[_0xb1d7('0xaa')],'as':'Tags','attributes':['id',_0xb1d7('0x39'),_0xb1d7('0xab')],'where':_0x32d0d5[_0xb1d7('0x43')]['tag']?{'id':_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0xac')]}:undefined,'required':_0x32d0d5[_0xb1d7('0x43')]['tag']?!![]:![]}];}return db[_0xb1d7('0x8d')][_0xb1d7('0x55')](_0x31eb39);})[_0xb1d7('0x34')](function(_0x4a93dd){_0x2b753c[_0xb1d7('0x56')]=_0x4a93dd;return _0x2b753c;});}})[_0xb1d7('0x34')](respondWithFilteredResult(_0x1c1826,_0x31eb39))['catch'](handleError(_0x1c1826,null));};exports[_0xb1d7('0xad')]=function(_0x566bb5,_0x4bef07,_0x57ad57){return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x566bb5[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x4bef07,null))['then'](function(_0x5076c4){if(_0x5076c4){return _0x5076c4[_0xb1d7('0xad')](_0x566bb5['body'][_0xb1d7('0x6b')],_['omit'](_0x566bb5[_0xb1d7('0x61')],[_0xb1d7('0x6b'),'id'])||{})[_0xb1d7('0x90')](function(_0x502086){for(var _0x1e3043=0x0;_0x1e3043<_0x566bb5[_0xb1d7('0x61')][_0xb1d7('0x6b')][_0xb1d7('0x49')];_0x1e3043+=0x1){socket[_0xb1d7('0xae')](_0xb1d7('0xaf'),{'UserId':_0x566bb5['body'][_0xb1d7('0x6b')][_0x1e3043],'OpenchannelAccountId':_0x566bb5[_0xb1d7('0x62')]['id']});}return _0x502086;});}})[_0xb1d7('0x34')](respondWithResult(_0x4bef07,null))[_0xb1d7('0x57')](handleError(_0x4bef07,null));};exports[_0xb1d7('0xb0')]=function(_0x3f1daf,_0x3f0ce0,_0x8f1c73){return db['OpenchannelAccount'][_0xb1d7('0x59')]({'where':{'id':_0x3f1daf['params']['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x3f0ce0,null))[_0xb1d7('0x34')](function(_0x4e1414){if(_0x4e1414){return _0x4e1414[_0xb1d7('0xb0')](_0x3f1daf['query'][_0xb1d7('0x6b')])[_0xb1d7('0x34')](function(){if(_[_0xb1d7('0xb1')](_0x3f1daf[_0xb1d7('0x43')]['ids'])){for(var _0x3b2e71=0x0;_0x3b2e71<_0x3f1daf[_0xb1d7('0x43')][_0xb1d7('0x6b')]['length'];_0x3b2e71+=0x1){socket[_0xb1d7('0xae')](_0xb1d7('0xb2'),{'UserId':Number(_0x3f1daf['query'][_0xb1d7('0x6b')][_0x3b2e71]),'OpenchannelAccountId':Number(_0x3f1daf[_0xb1d7('0x62')]['id'])});}}else{socket[_0xb1d7('0xae')](_0xb1d7('0xb2'),{'UserId':Number(_0x3f1daf['query']['ids']),'OpenchannelAccountId':Number(_0x3f1daf['params']['id'])});}});}})[_0xb1d7('0x34')](respondWithStatusCode(_0x3f0ce0,null))[_0xb1d7('0x57')](handleError(_0x3f0ce0,null));};exports[_0xb1d7('0xb3')]=function(_0x4045b8,_0x1b2c29,_0x5d03d9){var _0x17dfb0={};var _0x31ef8d={};var _0x161835;var _0x191855;return db[_0xb1d7('0x52')]['findOne']({'where':{'id':_0x4045b8[_0xb1d7('0x62')]['id']}})['then'](handleEntityNotFound(_0x1b2c29,null))[_0xb1d7('0x34')](function(_0x229338){if(_0x229338){_0x161835=_0x229338;_0x31ef8d['model']=_[_0xb1d7('0x44')](db[_0xb1d7('0x9a')][_0xb1d7('0x3e')]);_0x31ef8d[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x4045b8[_0xb1d7('0x43')]);_0x31ef8d['filters']=_[_0xb1d7('0x46')](_0x31ef8d['model'],_0x31ef8d[_0xb1d7('0x43')]);_0x17dfb0['attributes']=_['intersection'](_0x31ef8d[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x4045b8[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x17dfb0[_0xb1d7('0x47')]=_0x17dfb0['attributes'][_0xb1d7('0x49')]?_0x17dfb0['attributes']:_0x31ef8d[_0xb1d7('0x42')];_0x17dfb0[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x4045b8[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x17dfb0[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_[_0xb1d7('0x69')](_0x4045b8['query'],_0x31ef8d['filters']));if(_0x4045b8['query'][_0xb1d7('0x4f')]){_0x17dfb0[_0xb1d7('0x4e')]=_[_0xb1d7('0x50')](_0x17dfb0['where'],{'$or':_[_0xb1d7('0x3d')](_0x17dfb0[_0xb1d7('0x47')],function(_0x5a005b){var _0x1db62b={};_0x1db62b[_0x5a005b]={'$like':'%'+_0x4045b8['query']['filter']+'%'};return _0x1db62b;})});}_0x17dfb0=_[_0xb1d7('0x50')]({},_0x17dfb0,_0x4045b8['options']);return _0x161835[_0xb1d7('0xb3')](_0x17dfb0);}})[_0xb1d7('0x34')](function(_0x4cb589){if(_0x4cb589){_0x191855=_0x4cb589['length'];if(!_0x4045b8[_0xb1d7('0x43')]['hasOwnProperty'](_0xb1d7('0x4b'))){_0x17dfb0[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x4045b8['query']['limit']);_0x17dfb0['offset']=qs['offset'](_0x4045b8['query'][_0xb1d7('0x2d')]);}return _0x161835[_0xb1d7('0xb3')](_0x17dfb0);}})[_0xb1d7('0x34')](function(_0x8b37b2){if(_0x8b37b2){return _0x8b37b2?{'count':_0x191855,'rows':_0x8b37b2}:null;}})['then'](respondWithResult(_0x1b2c29,null))[_0xb1d7('0x57')](handleError(_0x1b2c29,null));};exports[_0xb1d7('0x3a')]=function(_0x4de1db,_0x590c12,_0x1dbc08){var _0x50ede4,_0x20ad58,_0x44877c;if(_['isNil'](_0x4de1db[_0xb1d7('0x61')]['body'])||_0x4de1db[_0xb1d7('0x61')][_0xb1d7('0x61')]===''){throw new db['Sequelize'][(_0xb1d7('0x75'))](_0xb1d7('0xb4'));}if(_[_0xb1d7('0x79')](_0x4de1db['body']['to'])){}_0x50ede4=_0x4de1db[_0xb1d7('0x61')]['to'];return db[_0xb1d7('0x52')]['findOne']({'where':{'id':_0x4de1db[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x590c12,null))[_0xb1d7('0x34')](function(_0x58de2d){if(_0x58de2d){return db['OpenchannelAccount']['find']({'where':{'id':_0x58de2d['id']},'include':[{'model':db['CmList'],'as':_0xb1d7('0x7f'),'include':[{'model':db[_0xb1d7('0x73')],'as':_0xb1d7('0x80'),'where':{[_0x58de2d[_0xb1d7('0x7b')]]:_0x50ede4},'limit':0x1,'order':[[_0xb1d7('0x81'),_0xb1d7('0x82')]]}]}]})[_0xb1d7('0x34')](handleEntityNotFound(_0x590c12,null))[_0xb1d7('0x34')](function(_0x326b4a){if(_0x326b4a&&_0x326b4a[_0xb1d7('0x7f')]){_0x20ad58=_0x326b4a[_0xb1d7('0x36')]({'plain':!![]});if(_0x20ad58[_0xb1d7('0x7f')]&&_0x20ad58['List'][_0xb1d7('0x80')][_0xb1d7('0x49')]){return _0x20ad58['List'][_0xb1d7('0x80')][0x0];}return db[_0xb1d7('0x73')][_0xb1d7('0x5f')](_['defaults'](_0x4de1db[_0xb1d7('0x61')],{'firstName':_0x50ede4,[_0x326b4a['mapKey']]:_0x50ede4,'phone':_0x50ede4,'ListId':_0x20ad58['ListId']}));}})[_0xb1d7('0x34')](handleEntityNotFound(_0x590c12,null))[_0xb1d7('0x34')](function(_0x4501cf){if(_0x4501cf){_0x44877c=_0x4501cf;return db[_0xb1d7('0x8d')][_0xb1d7('0x59')]({'where':{'ContactId':_0x44877c['id'],'closed':![],'OpenchannelAccountId':_0x20ad58['id']}})[_0xb1d7('0x34')](function(_0x80785b){if(_0x80785b){return[_0x80785b,![]];}return db[_0xb1d7('0x8d')]['create']({'UserId':_0x4de1db['user']['id'],'ContactId':_0x44877c['id'],'OpenchannelAccountId':_0x20ad58['id'],'lastMsgDirection':'out','Messages':[_[_0xb1d7('0x50')](_0x4de1db[_0xb1d7('0x61')],{'read':![],'body':_0x4de1db['body'][_0xb1d7('0x61')],'OpenchannelAccountId':_0x20ad58['id'],'UserId':_0x4de1db['user']['id'],'ContactId':_0x44877c['id']})]},{'include':[{'model':db[_0xb1d7('0xb5')],'as':_0xb1d7('0xb6')}]})['then'](function(_0x480b22){return[_0x480b22,!![]];});});}})[_0xb1d7('0x90')](function(_0x3a816e,_0x5b5ba2){if(_0x5b5ba2){return _0x3a816e;}return db[_0xb1d7('0xb5')][_0xb1d7('0x5f')](_[_0xb1d7('0x50')](_0x4de1db[_0xb1d7('0x61')],{'read':![],'body':_0x4de1db[_0xb1d7('0x61')][_0xb1d7('0x61')],'OpenchannelAccountId':_0x20ad58['id'],'OpenchannelInteractionId':_0x3a816e['id'],'UserId':_0x4de1db[_0xb1d7('0x5a')]['id'],'ContactId':_0x44877c['id']}))[_0xb1d7('0x34')](function(_0x4d3907){_0x3a816e[_0xb1d7('0xb7')][_0xb1d7('0xb6')]=[];_0x3a816e[_0xb1d7('0xb7')]['Messages']['push'](_0x4d3907[_0xb1d7('0xb7')]);return _0x3a816e;});});}})[_0xb1d7('0x34')](respondWithResult(_0x590c12,null))[_0xb1d7('0x57')](handleError(_0x590c12,null));};
\ No newline at end of file