Built motion from commit (unavailable).|2.5.18
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index fda4322..0fb2848 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb564=['removeAgents','isArray','userOpenchannelAccount:remove','getAgents','DESC','out','Messages','dataValues','push','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','jayson/promise','client','http','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','request\x20sent','error','code','OpenchannelAccount,\x20%s,\x20%s','message','catch','status','end','count','offset','set','json','apply','reject','save','update','get','OpenchannelAccounts','UserProfileResource','destroy','sendStatus','name','send','index','mandatoryDispositionPause','map','OpenchannelAccount','rawAttributes','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','filters','pick','where','merge','VIRTUAL','filter','include','show','params','Pause','includeAll','options','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','OpnechannelAccountId','Disposition','getDispositions','OpenchannelAccountId','findAll','rows','removeDispositions','ids','addAnswer','CannedAnswer','removeAnswers','CmContact','difference','createdAt','updatedAt','CompanyId','ListId','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','includes','mapKey','CmList','List','Contacts','OpenchannelApplication','applications','orderBy','priority','asc','account','Applications','firstName','lastName','threadId','externalUrl','OpenchannelInteraction','ContactId','spread','contact','messageId','interaction','created','autoclose','close','unmanaged','*,*,*,*','OpenchannelMessage','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','EventManager','notify','sequelize','transaction','bulkCreate','getApplications','findOne','getInteractions','Contact','Tag','Tags','tag','addAgents','emit','userOpenchannelAccount:save'];(function(_0x5f1e86,_0x94075e){var _0x3e45ab=function(_0x2b6b47){while(--_0x2b6b47){_0x5f1e86['push'](_0x5f1e86['shift']());}};_0x3e45ab(++_0x94075e);}(_0xb564,0xbf));var _0x4b56=function(_0x1fc87b,_0x5f2d93){_0x1fc87b=_0x1fc87b-0x0;var _0xfbb425=_0xb564[_0x1fc87b];return _0xfbb425;};'use strict';var pdf=require(_0x4b56('0x0'));var emlformat=require(_0x4b56('0x1'));var rimraf=require(_0x4b56('0x2'));var zipdir=require(_0x4b56('0x3'));var jsonpatch=require(_0x4b56('0x4'));var rp=require(_0x4b56('0x5'));var moment=require(_0x4b56('0x6'));var BPromise=require(_0x4b56('0x7'));var Mustache=require(_0x4b56('0x8'));var util=require(_0x4b56('0x9'));var path=require('path');var sox=require(_0x4b56('0xa'));var csv=require(_0x4b56('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x4b56('0xc'));var squel=require(_0x4b56('0xd'));var crypto=require(_0x4b56('0xe'));var jsforce=require(_0x4b56('0xf'));var deskjs=require(_0x4b56('0x10'));var toCsv=require(_0x4b56('0xb'));var querystring=require(_0x4b56('0x11'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x4b56('0x12'));var qs=require(_0x4b56('0x13'));var as=require(_0x4b56('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x4b56('0x15'))(_0x4b56('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var db=require(_0x4b56('0x17'))['db'];config[_0x4b56('0x18')]=_[_0x4b56('0x19')](config[_0x4b56('0x18')],{'host':_0x4b56('0x1a'),'port':0x18eb});var socket=require(_0x4b56('0x1b'))(new Redis(config[_0x4b56('0x18')]));require('./openchannelAccount.socket')[_0x4b56('0x1c')](socket);var jayson=require(_0x4b56('0x1d'));var client=jayson[_0x4b56('0x1e')][_0x4b56('0x1f')]({'port':0x232c});var client9002=jayson[_0x4b56('0x1e')][_0x4b56('0x1f')]({'port':0x232a});function checkPasswordPattern(_0x46b897,_0x345e5c,_0x31c464){if(_0x31c464){var _0x8281f8=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x8281f8['test'](_0x345e5c)){return _0x46b897;}else{throw new db[(_0x4b56('0x20'))][(_0x4b56('0x21'))](_0x4b56('0x22'));}}else{return _0x46b897;}}function respondWithRpcPromise(_0x11a1aa,_0x5ecfa5,_0x79b3aa,_0x11cf0f){return new BPromise(function(_0x5b9d3e,_0x9b6a16){var _0x585b90=_0x11cf0f||client;return _0x585b90[_0x4b56('0x23')](_0x11a1aa,_0x79b3aa)[_0x4b56('0x24')](function(_0x2313af){logger[_0x4b56('0x25')]('OpenchannelAccount,\x20%s,\x20%s',_0x5ecfa5,'request\x20sent');logger['debug']('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0x5ecfa5,_0x4b56('0x26'),JSON['stringify'](_0x2313af));if(_0x2313af[_0x4b56('0x27')]){if(_0x2313af['error'][_0x4b56('0x28')]===0x1f4){logger[_0x4b56('0x27')](_0x4b56('0x29'),_0x5ecfa5,_0x2313af['error'][_0x4b56('0x2a')]);return _0x9b6a16(_0x2313af[_0x4b56('0x27')]['message']);}logger[_0x4b56('0x27')](_0x4b56('0x29'),_0x5ecfa5,_0x2313af[_0x4b56('0x27')]['message']);return _0x5b9d3e(_0x2313af[_0x4b56('0x27')][_0x4b56('0x2a')]);}else{logger[_0x4b56('0x25')](_0x4b56('0x29'),_0x5ecfa5,'request\x20sent');_0x5b9d3e(_0x2313af['result'][_0x4b56('0x2a')]);}})[_0x4b56('0x2b')](function(_0x3df4fe){logger['error'](_0x4b56('0x29'),_0x5ecfa5,_0x3df4fe);_0x9b6a16(_0x3df4fe);});});}function respondWithStatusCode(_0x85929e,_0x5de01c){_0x5de01c=_0x5de01c||0xcc;return function(_0x310260){if(_0x310260){return _0x85929e['sendStatus'](_0x5de01c);}return _0x85929e[_0x4b56('0x2c')](_0x5de01c)[_0x4b56('0x2d')]();};}function respondWithResult(_0x28f950,_0x31abf7){_0x31abf7=_0x31abf7||0xc8;return function(_0x5697f6){if(_0x5697f6){return _0x28f950[_0x4b56('0x2c')](_0x31abf7)['json'](_0x5697f6);}};}function respondWithFilteredResult(_0x26aad3,_0x53f1aa){return function(_0x2d31ce){if(_0x2d31ce){var _0x33e772=_0x2d31ce[_0x4b56('0x2e')],_0x65fba=_0x53f1aa[_0x4b56('0x2f')],_0x184e7c=_0x53f1aa['offset']+_0x53f1aa['limit'],_0x2e05ab;if(_0x184e7c>=_0x33e772){_0x184e7c=_0x33e772;_0x2e05ab=0xc8;}else{_0x2e05ab=0xce;}_0x26aad3[_0x4b56('0x2c')](_0x2e05ab);return _0x26aad3[_0x4b56('0x30')]('Content-Range',_0x65fba+'-'+_0x184e7c+'/'+_0x33e772)[_0x4b56('0x31')](_0x2d31ce);}return null;};}function patchUpdates(_0x45434b){return function(_0xa70263){try{jsonpatch[_0x4b56('0x32')](_0xa70263,_0x45434b,!![]);}catch(_0x2624de){return BPromise[_0x4b56('0x33')](_0x2624de);}return _0xa70263[_0x4b56('0x34')]();};}function saveUpdates(_0x2f9fcb,_0x9ef8dd){return function(_0x568666){if(_0x568666){return _0x568666[_0x4b56('0x35')](_0x2f9fcb)[_0x4b56('0x24')](function(_0x43d06b){return _0x43d06b;});}return null;};}function removeEntity(_0x767c0,_0x424c80){return function(_0x2c001a){if(_0x2c001a){return _0x2c001a['destroy']()['then'](function(){var _0x299166=_0x2c001a[_0x4b56('0x36')]({'plain':!![]});var _0x1e289b=_0x4b56('0x37');return db[_0x4b56('0x38')][_0x4b56('0x39')]({'where':{'type':_0x1e289b,'resourceId':_0x299166['id']}})[_0x4b56('0x24')](function(){return _0x2c001a;});})['then'](function(){_0x767c0[_0x4b56('0x2c')](0xcc)[_0x4b56('0x2d')]();});}};}function handleEntityNotFound(_0x3e2dfd,_0x35b73a){return function(_0x234fcc){if(!_0x234fcc){_0x3e2dfd[_0x4b56('0x3a')](0x194);}return _0x234fcc;};}function handleError(_0x4c75d5,_0x3edaea){_0x3edaea=_0x3edaea||0x1f4;return function(_0x2116dc){logger[_0x4b56('0x27')](_0x2116dc['stack']);if(_0x2116dc[_0x4b56('0x3b')]){delete _0x2116dc[_0x4b56('0x3b')];}_0x4c75d5[_0x4b56('0x2c')](_0x3edaea)[_0x4b56('0x3c')](_0x2116dc);};}exports[_0x4b56('0x3d')]=function(_0x31dce1,_0x2b754a){var _0x1ef8cf={'include':[{'model':db['Pause'],'as':_0x4b56('0x3e')}]},_0x45a3d1={},_0x47d697={'count':0x0,'rows':[]};var _0x400747=_[_0x4b56('0x3f')](db[_0x4b56('0x40')][_0x4b56('0x41')],function(_0x390035){return{'name':_0x390035['fieldName'],'type':_0x390035[_0x4b56('0x42')][_0x4b56('0x43')]};});_0x45a3d1[_0x4b56('0x44')]=_[_0x4b56('0x3f')](_0x400747,'name');_0x45a3d1[_0x4b56('0x45')]=_[_0x4b56('0x46')](_0x31dce1[_0x4b56('0x45')]);_0x45a3d1['filters']=_[_0x4b56('0x47')](_0x45a3d1['model'],_0x45a3d1[_0x4b56('0x45')]);_0x1ef8cf[_0x4b56('0x48')]=_['intersection'](_0x45a3d1[_0x4b56('0x44')],qs[_0x4b56('0x49')](_0x31dce1[_0x4b56('0x45')][_0x4b56('0x49')]));_0x1ef8cf['attributes']=_0x1ef8cf[_0x4b56('0x48')][_0x4b56('0x4a')]?_0x1ef8cf[_0x4b56('0x48')]:_0x45a3d1['model'];if(!_0x31dce1[_0x4b56('0x45')][_0x4b56('0x4b')](_0x4b56('0x4c'))){_0x1ef8cf['limit']=qs['limit'](_0x31dce1['query'][_0x4b56('0x4d')]);_0x1ef8cf[_0x4b56('0x2f')]=qs[_0x4b56('0x2f')](_0x31dce1['query'][_0x4b56('0x2f')]);}_0x1ef8cf[_0x4b56('0x4e')]=qs[_0x4b56('0x4f')](_0x31dce1[_0x4b56('0x45')][_0x4b56('0x4f')]);_0x1ef8cf['where']=qs[_0x4b56('0x50')](_[_0x4b56('0x51')](_0x31dce1[_0x4b56('0x45')],_0x45a3d1[_0x4b56('0x50')]));if(_0x31dce1[_0x4b56('0x45')]['filter']){_0x1ef8cf[_0x4b56('0x52')]=_[_0x4b56('0x53')](_0x1ef8cf[_0x4b56('0x52')],{'$or':_[_0x4b56('0x3f')](_0x400747,function(_0x427ccc){if(_0x427ccc[_0x4b56('0x42')]!==_0x4b56('0x54')){var _0x1ca43a={};_0x1ca43a[_0x427ccc[_0x4b56('0x3b')]]={'$like':'%'+_0x31dce1[_0x4b56('0x45')][_0x4b56('0x55')]+'%'};return _0x1ca43a;}})});}_0x1ef8cf=_[_0x4b56('0x53')]({},_0x1ef8cf,_0x31dce1['options']);var _0x137137={'where':_0x1ef8cf['where']};return db['OpenchannelAccount']['count'](_0x137137)[_0x4b56('0x24')](function(_0x4486fd){_0x47d697['count']=_0x4486fd;if(_0x31dce1[_0x4b56('0x45')]['includeAll']){_0x1ef8cf[_0x4b56('0x56')]=[{'all':!![]}];}return db[_0x4b56('0x40')]['findAll'](_0x1ef8cf);})['then'](function(_0x5656f5){_0x47d697['rows']=_0x5656f5;return _0x47d697;})[_0x4b56('0x24')](respondWithFilteredResult(_0x2b754a,_0x1ef8cf))['catch'](handleError(_0x2b754a,null));};exports[_0x4b56('0x57')]=function(_0xd1283c,_0x386a9f){var _0x13d134={'raw':![],'where':{'id':_0xd1283c[_0x4b56('0x58')]['id']},'include':[{'model':db[_0x4b56('0x59')],'as':_0x4b56('0x3e')}]},_0x139ea8={};_0x139ea8[_0x4b56('0x44')]=_['keys'](db['OpenchannelAccount'][_0x4b56('0x41')]);_0x139ea8[_0x4b56('0x45')]=_[_0x4b56('0x46')](_0xd1283c[_0x4b56('0x45')]);_0x139ea8[_0x4b56('0x50')]=_['intersection'](_0x139ea8[_0x4b56('0x44')],_0x139ea8[_0x4b56('0x45')]);_0x13d134['attributes']=_[_0x4b56('0x47')](_0x139ea8[_0x4b56('0x44')],qs[_0x4b56('0x49')](_0xd1283c[_0x4b56('0x45')][_0x4b56('0x49')]));_0x13d134[_0x4b56('0x48')]=_0x13d134['attributes'][_0x4b56('0x4a')]?_0x13d134[_0x4b56('0x48')]:_0x139ea8[_0x4b56('0x44')];if(_0xd1283c['query'][_0x4b56('0x5a')]){_0x13d134[_0x4b56('0x56')]=[{'all':!![]}];}_0x13d134=_['merge']({},_0x13d134,_0xd1283c[_0x4b56('0x5b')]);return db['OpenchannelAccount'][_0x4b56('0x5c')](_0x13d134)[_0x4b56('0x24')](handleEntityNotFound(_0x386a9f,null))[_0x4b56('0x24')](respondWithResult(_0x386a9f,null))['catch'](handleError(_0x386a9f,null));};exports[_0x4b56('0x5d')]=function(_0x201a82,_0x242432){return db[_0x4b56('0x40')]['create'](_0x201a82[_0x4b56('0x5e')],{})[_0x4b56('0x24')](function(_0x4273ee){var _0x3b8ff5=_0x201a82['user'][_0x4b56('0x36')]({'plain':!![]});if(!_0x3b8ff5)throw new Error(_0x4b56('0x5f'));if(_0x3b8ff5[_0x4b56('0x60')]===_0x4b56('0x61')){var _0x211436=_0x4273ee[_0x4b56('0x36')]({'plain':!![]});var _0x37d414=_0x4b56('0x37');return db[_0x4b56('0x62')][_0x4b56('0x5c')]({'where':{'name':_0x37d414,'userProfileId':_0x3b8ff5['userProfileId']},'raw':!![]})[_0x4b56('0x24')](function(_0x10f9bd){if(_0x10f9bd&&_0x10f9bd[_0x4b56('0x63')]===0x0){return db['UserProfileResource'][_0x4b56('0x5d')]({'name':_0x211436['name'],'resourceId':_0x211436['id'],'type':_0x10f9bd[_0x4b56('0x3b')],'sectionId':_0x10f9bd['id']},{})[_0x4b56('0x24')](function(){return _0x4273ee;});}else{return _0x4273ee;}})['catch'](function(_0x4860e4){logger[_0x4b56('0x27')](_0x4b56('0x64'),_0x4860e4);throw _0x4860e4;});}return _0x4273ee;})[_0x4b56('0x24')](respondWithResult(_0x242432,0xc9))[_0x4b56('0x2b')](handleError(_0x242432,null));};exports[_0x4b56('0x35')]=function(_0x307994,_0x3f500d){if(_0x307994[_0x4b56('0x5e')]['id']){delete _0x307994['body']['id'];}return db[_0x4b56('0x40')][_0x4b56('0x5c')]({'where':{'id':_0x307994[_0x4b56('0x58')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]})[_0x4b56('0x24')](handleEntityNotFound(_0x3f500d,null))[_0x4b56('0x24')](saveUpdates(_0x307994[_0x4b56('0x5e')],null))['then'](respondWithResult(_0x3f500d,null))[_0x4b56('0x2b')](handleError(_0x3f500d,null));};exports[_0x4b56('0x39')]=function(_0x6ffabd,_0x3b85bd){return db[_0x4b56('0x40')][_0x4b56('0x5c')]({'where':{'id':_0x6ffabd[_0x4b56('0x58')]['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x3b85bd,null))[_0x4b56('0x24')](removeEntity(_0x3b85bd,null))[_0x4b56('0x2b')](handleError(_0x3b85bd,null));};exports[_0x4b56('0x65')]=function(_0x33201f,_0x2762a1){return db[_0x4b56('0x40')][_0x4b56('0x65')]()[_0x4b56('0x24')](respondWithResult(_0x2762a1,null))[_0x4b56('0x2b')](handleError(_0x2762a1,null));};exports[_0x4b56('0x66')]=function(_0x2bc915,_0x2767a9,_0x521c72){if(_0x2bc915[_0x4b56('0x5e')]['id']){delete _0x2bc915[_0x4b56('0x5e')]['id'];}return db['OpenchannelAccount'][_0x4b56('0x5c')]({'where':{'id':_0x2bc915[_0x4b56('0x58')]['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x2767a9,null))[_0x4b56('0x24')](function(_0x3116ce){if(_0x3116ce){_0x2bc915[_0x4b56('0x5e')][_0x4b56('0x67')]=_0x3116ce['id'];return db[_0x4b56('0x68')][_0x4b56('0x5d')](_0x2bc915[_0x4b56('0x5e')]);}})[_0x4b56('0x24')](respondWithResult(_0x2767a9,null))[_0x4b56('0x2b')](handleError(_0x2767a9,null));};exports[_0x4b56('0x69')]=function(_0x357a40,_0x50ae67,_0xa04a7d){var _0x4e0306={'raw':![],'where':{}};var _0x47d9fd={};var _0x54ff57={'count':0x0,'rows':[]};return db[_0x4b56('0x40')]['findOne']({'where':{'id':_0x357a40[_0x4b56('0x58')]['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x50ae67,null))['then'](function(_0xc663d8){if(_0xc663d8){_0x47d9fd[_0x4b56('0x44')]=_[_0x4b56('0x46')](db[_0x4b56('0x68')][_0x4b56('0x41')]);_0x47d9fd[_0x4b56('0x45')]=_[_0x4b56('0x46')](_0x357a40[_0x4b56('0x45')]);_0x47d9fd['filters']=_['intersection'](_0x47d9fd[_0x4b56('0x44')],_0x47d9fd[_0x4b56('0x45')]);_0x4e0306[_0x4b56('0x48')]=_[_0x4b56('0x47')](_0x47d9fd[_0x4b56('0x44')],qs[_0x4b56('0x49')](_0x357a40[_0x4b56('0x45')][_0x4b56('0x49')]));_0x4e0306['attributes']=_0x4e0306[_0x4b56('0x48')]['length']?_0x4e0306[_0x4b56('0x48')]:_0x47d9fd[_0x4b56('0x44')];if(!_0x357a40[_0x4b56('0x45')][_0x4b56('0x4b')](_0x4b56('0x4c'))){_0x4e0306['limit']=qs[_0x4b56('0x4d')](_0x357a40[_0x4b56('0x45')][_0x4b56('0x4d')]);_0x4e0306[_0x4b56('0x2f')]=qs[_0x4b56('0x2f')](_0x357a40[_0x4b56('0x45')][_0x4b56('0x2f')]);}_0x4e0306[_0x4b56('0x4e')]=qs[_0x4b56('0x4f')](_0x357a40[_0x4b56('0x45')][_0x4b56('0x4f')]);_0x4e0306['where']=qs[_0x4b56('0x50')](_['pick'](_0x357a40[_0x4b56('0x45')],_0x47d9fd['filters']));_0x4e0306[_0x4b56('0x52')][_0x4b56('0x6a')]=_0xc663d8['id'];if(_0x357a40['query'][_0x4b56('0x55')]){_0x4e0306[_0x4b56('0x52')]=_[_0x4b56('0x53')](_0x4e0306['where'],{'$or':_['map'](_0x4e0306[_0x4b56('0x48')],function(_0x58a5ad){var _0x527acf={};_0x527acf[_0x58a5ad]={'$like':'%'+_0x357a40[_0x4b56('0x45')][_0x4b56('0x55')]+'%'};return _0x527acf;})});}_0x4e0306=_[_0x4b56('0x53')]({},_0x4e0306,_0x357a40[_0x4b56('0x5b')]);return db[_0x4b56('0x68')][_0x4b56('0x2e')]({'where':_0x4e0306[_0x4b56('0x52')]})[_0x4b56('0x24')](function(_0x22903f){_0x54ff57['count']=_0x22903f;if(_0x357a40['query'][_0x4b56('0x5a')]){_0x4e0306[_0x4b56('0x56')]=[{'all':!![]}];}return db['Disposition'][_0x4b56('0x6b')](_0x4e0306);})[_0x4b56('0x24')](function(_0x308eac){_0x54ff57[_0x4b56('0x6c')]=_0x308eac;return _0x54ff57;});}})['then'](respondWithFilteredResult(_0x50ae67,_0x4e0306))[_0x4b56('0x2b')](handleError(_0x50ae67,null));};exports['removeDispositions']=function(_0x27a493,_0x11e2f6,_0x1df379){return db[_0x4b56('0x40')][_0x4b56('0x5c')]({'where':{'id':_0x27a493['params']['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x11e2f6,null))[_0x4b56('0x24')](function(_0x51ab5f){if(_0x51ab5f){return _0x51ab5f[_0x4b56('0x6d')](_0x27a493['query'][_0x4b56('0x6e')]);}})[_0x4b56('0x24')](respondWithStatusCode(_0x11e2f6,null))['catch'](handleError(_0x11e2f6,null));};exports[_0x4b56('0x6f')]=function(_0x45e679,_0x69ed71,_0x1ab7eb){if(_0x45e679['body']['id']){delete _0x45e679[_0x4b56('0x5e')]['id'];}return db[_0x4b56('0x40')][_0x4b56('0x5c')]({'where':{'id':_0x45e679['params']['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x69ed71,null))[_0x4b56('0x24')](function(_0x3a0a17){if(_0x3a0a17){_0x45e679['body']['OpenchannelAccountId']=_0x3a0a17['id'];return db[_0x4b56('0x70')]['create'](_0x45e679[_0x4b56('0x5e')]);}})[_0x4b56('0x24')](respondWithResult(_0x69ed71,null))[_0x4b56('0x2b')](handleError(_0x69ed71,null));};exports['getAnswers']=function(_0x474c0a,_0x1b5300,_0xa7a3f9){var _0x144980={'raw':![],'where':{}};var _0x449f01={};var _0x292acc={'count':0x0,'rows':[]};return db[_0x4b56('0x40')]['findOne']({'where':{'id':_0x474c0a[_0x4b56('0x58')]['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x1b5300,null))['then'](function(_0x3849ad){if(_0x3849ad){_0x449f01[_0x4b56('0x44')]=_['keys'](db['CannedAnswer']['rawAttributes']);_0x449f01[_0x4b56('0x45')]=_[_0x4b56('0x46')](_0x474c0a['query']);_0x449f01[_0x4b56('0x50')]=_[_0x4b56('0x47')](_0x449f01[_0x4b56('0x44')],_0x449f01[_0x4b56('0x45')]);_0x144980[_0x4b56('0x48')]=_[_0x4b56('0x47')](_0x449f01[_0x4b56('0x44')],qs[_0x4b56('0x49')](_0x474c0a[_0x4b56('0x45')]['fields']));_0x144980[_0x4b56('0x48')]=_0x144980['attributes']['length']?_0x144980[_0x4b56('0x48')]:_0x449f01[_0x4b56('0x44')];if(!_0x474c0a[_0x4b56('0x45')][_0x4b56('0x4b')](_0x4b56('0x4c'))){_0x144980[_0x4b56('0x4d')]=qs['limit'](_0x474c0a[_0x4b56('0x45')]['limit']);_0x144980[_0x4b56('0x2f')]=qs[_0x4b56('0x2f')](_0x474c0a[_0x4b56('0x45')][_0x4b56('0x2f')]);}_0x144980[_0x4b56('0x4e')]=qs[_0x4b56('0x4f')](_0x474c0a[_0x4b56('0x45')]['sort']);_0x144980[_0x4b56('0x52')]=qs[_0x4b56('0x50')](_[_0x4b56('0x51')](_0x474c0a[_0x4b56('0x45')],_0x449f01[_0x4b56('0x50')]));_0x144980['where'][_0x4b56('0x6a')]=_0x3849ad['id'];if(_0x474c0a[_0x4b56('0x45')][_0x4b56('0x55')]){_0x144980[_0x4b56('0x52')]=_['merge'](_0x144980['where'],{'$or':_[_0x4b56('0x3f')](_0x144980['attributes'],function(_0x1f4156){var _0x5c6c99={};_0x5c6c99[_0x1f4156]={'$like':'%'+_0x474c0a[_0x4b56('0x45')][_0x4b56('0x55')]+'%'};return _0x5c6c99;})});}_0x144980=_[_0x4b56('0x53')]({},_0x144980,_0x474c0a[_0x4b56('0x5b')]);return db[_0x4b56('0x70')][_0x4b56('0x2e')]({'where':_0x144980['where']})[_0x4b56('0x24')](function(_0x2aee3a){_0x292acc['count']=_0x2aee3a;if(_0x474c0a['query'][_0x4b56('0x5a')]){_0x144980[_0x4b56('0x56')]=[{'all':!![]}];}return db[_0x4b56('0x70')][_0x4b56('0x6b')](_0x144980);})[_0x4b56('0x24')](function(_0x812ef3){_0x292acc[_0x4b56('0x6c')]=_0x812ef3;return _0x292acc;});}})['then'](respondWithFilteredResult(_0x1b5300,_0x144980))[_0x4b56('0x2b')](handleError(_0x1b5300,null));};exports[_0x4b56('0x71')]=function(_0x3aa164,_0x604f53,_0x14521b){return db[_0x4b56('0x40')][_0x4b56('0x5c')]({'where':{'id':_0x3aa164['params']['id']}})['then'](handleEntityNotFound(_0x604f53,null))[_0x4b56('0x24')](function(_0x133047){if(_0x133047){return _0x133047['removeAnswers'](_0x3aa164[_0x4b56('0x45')][_0x4b56('0x6e')]);}})['then'](respondWithStatusCode(_0x604f53,null))[_0x4b56('0x2b')](handleError(_0x604f53,null));};exports['notify']=function(_0x332c3c,_0x1def43,_0x2557ba){var _0x2f8abc={'body':_0x332c3c[_0x4b56('0x5e')],'channel':'openchannel'};var _0x412f81=[];var _0x586984=[];var _0x2923d9={};var _0x3247dd=![];return db[_0x4b56('0x72')][_0x4b56('0x65')]()[_0x4b56('0x24')](function(_0x249395){if(!_0x249395){throw new db['Sequelize']['ValidationError']('no\x20available\x20attributes');}_0x412f81=_[_0x4b56('0x73')](_[_0x4b56('0x46')](_0x249395),[_0x4b56('0x74'),_0x4b56('0x75')]);_0x586984=_['difference'](_[_0x4b56('0x46')](_0x249395),[_0x4b56('0x74'),_0x4b56('0x75'),_0x4b56('0x76'),_0x4b56('0x77')]);if(_0x332c3c[_0x4b56('0x5e')]['id']){delete _0x332c3c[_0x4b56('0x5e')]['id'];}if(_[_0x4b56('0x78')](_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x79')])){throw new db[(_0x4b56('0x20'))][(_0x4b56('0x21'))](_0x4b56('0x7a'));}if(_[_0x4b56('0x78')](_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x5e')])||_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x5e')]===''){throw new db['Sequelize']['ValidationError'](_0x4b56('0x7b'));}if(_[_0x4b56('0x78')](_0x332c3c[_0x4b56('0x5e')]['mapKey'])){throw new db[(_0x4b56('0x20'))][(_0x4b56('0x21'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x586984);}if(!_[_0x4b56('0x7c')](_0x586984,_0x332c3c['body']['mapKey'])){throw new db[(_0x4b56('0x20'))][(_0x4b56('0x21'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x586984);}_0x2923d9[_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x7d')]]=_0x332c3c['body'][_0x4b56('0x79')];})[_0x4b56('0x24')](function(){return db['OpenchannelAccount']['find']({'where':{'id':_0x332c3c['params']['id']},'include':[{'model':db[_0x4b56('0x7e')],'as':_0x4b56('0x7f'),'include':[{'model':db[_0x4b56('0x72')],'as':_0x4b56('0x80'),'where':_0x2923d9,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db[_0x4b56('0x81')],'as':'Applications'}]});})[_0x4b56('0x24')](handleEntityNotFound(_0x1def43,null))[_0x4b56('0x24')](function(_0x2fc1f1){if(_0x2fc1f1&&_0x2fc1f1[_0x4b56('0x7f')]){_0x2f8abc['account']=_0x2fc1f1;_0x2f8abc[_0x4b56('0x82')]=_0x2fc1f1['Applications'];_0x2f8abc['list']=_0x2fc1f1['List'];_0x2f8abc['applications']=_[_0x4b56('0x83')](_0x2f8abc['applications'],[_0x4b56('0x84')],[_0x4b56('0x85')]);if(_0x2f8abc[_0x4b56('0x86')]['Applications']){delete _0x2f8abc[_0x4b56('0x86')][_0x4b56('0x87')];}if(_0x2f8abc['account'][_0x4b56('0x7f')]&&_0x2f8abc[_0x4b56('0x86')][_0x4b56('0x7f')]['Contacts'][_0x4b56('0x4a')]){return _0x2f8abc[_0x4b56('0x86')][_0x4b56('0x7f')]['Contacts'][0x0];}var _0x3d44c3=_['defaults'](_0x332c3c[_0x4b56('0x5e')],{'firstName':_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x79')],'ListId':_0x2fc1f1['ListId']});_0x3d44c3[_0x332c3c[_0x4b56('0x5e')]['mapKey']]=_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x79')];return db[_0x4b56('0x72')][_0x4b56('0x5d')](_0x3d44c3,{'fields':_0x412f81,'raw':!![]});}})['then'](handleEntityNotFound(_0x1def43,null))[_0x4b56('0x24')](function(_0x2508f5){_0x2f8abc['contact']=_0x2508f5;if(_0x2508f5){var _0xab8209={'ContactId':_0x2508f5['id'],'OpenchannelAccountId':_0x332c3c[_0x4b56('0x58')]['id'],'from':(_0x2508f5[_0x4b56('0x88')]||'')+'\x20'+(_0x2508f5[_0x4b56('0x89')]||'')};var _0xe1c159={'OpenchannelAccountId':_0x332c3c[_0x4b56('0x58')]['id'],'closed':![]};if(_0x332c3c['body'][_0x4b56('0x8a')]){_0xe1c159[_0x4b56('0x8a')]=_0x332c3c[_0x4b56('0x5e')]['threadId'];return db['OpenchannelInteraction'][_0x4b56('0x5c')]({'where':_0xe1c159})[_0x4b56('0x24')](function(_0x21edf6){if(_0x21edf6){return[_0x21edf6,![]];}_0xab8209['threadId']=_0x332c3c[_0x4b56('0x5e')]['threadId'];_0xab8209[_0x4b56('0x8b')]=_0x332c3c['body'][_0x4b56('0x8b')];return db[_0x4b56('0x8c')][_0x4b56('0x5d')](_0xab8209)[_0x4b56('0x24')](function(_0x2d077d){return[_0x2d077d,!![]];});});}else{_0xe1c159[_0x4b56('0x8a')]=null;}_0xe1c159[_0x4b56('0x8d')]=_0x2508f5['id'];return db['OpenchannelInteraction']['find']({'where':_0xe1c159})[_0x4b56('0x24')](function(_0x71fee8){if(_0x71fee8){return[_0x71fee8,![]];}return db[_0x4b56('0x8c')][_0x4b56('0x5d')](_0xab8209)[_0x4b56('0x24')](function(_0x23253d){return[_0x23253d,!![]];});});}})[_0x4b56('0x8e')](function(_0x149a9d,_0x252548){if(_0x149a9d){_0x3247dd=_0x252548;if(!_0x252548){var _0x566b37={'from':(_0x2f8abc[_0x4b56('0x8f')][_0x4b56('0x88')]||'')+'\x20'+(_0x2f8abc[_0x4b56('0x8f')][_0x4b56('0x89')]||'')};if(_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x8a')]&&_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x90')]&&_0x332c3c['body']['threadId']!=_0x332c3c['body'][_0x4b56('0x90')]){_0x566b37[_0x4b56('0x8a')]=_0x332c3c['body']['messageId'];}return _0x149a9d['update'](_0x566b37);}else{return _0x149a9d;}}})[_0x4b56('0x24')](function(_0x5d9a7d){_0x2f8abc['interaction']=_0x5d9a7d[_0x4b56('0x36')]({'plain':!![]});_0x2f8abc[_0x4b56('0x91')][_0x4b56('0x92')]=_0x3247dd;if(_0x2f8abc['interaction'][_0x4b56('0x92')]){if(_0x2f8abc[_0x4b56('0x86')][_0x4b56('0x93')]){_0x2f8abc[_0x4b56('0x82')]['push']({'id':0x0,'priority':_0x2f8abc[_0x4b56('0x82')]['length']+0x1,'app':_0x4b56('0x94'),'appdata':_0x4b56('0x95'),'interval':_0x4b56('0x96')});}}return db[_0x4b56('0x97')][_0x4b56('0x5d')]({'body':_0x332c3c[_0x4b56('0x5e')][_0x4b56('0x5e')],'OpenchannelAccountId':_0x332c3c[_0x4b56('0x58')]['id'],'OpenchannelInteractionId':_0x5d9a7d['id'],'direction':'in','ContactId':_0x2f8abc[_0x4b56('0x8f')]['id'],'AttachmentId':_0x332c3c[_0x4b56('0x5e')]['AttachmentId']});})[_0x4b56('0x24')](function(_0x516d48){_0x2f8abc['message']=_0x516d48;if(_0x2f8abc[_0x4b56('0x91')][_0x4b56('0x98')]){return db['User'][_0x4b56('0x5c')]({'attributes':['id',_0x4b56('0x3b')],'where':{'id':_0x2f8abc[_0x4b56('0x91')]['UserId']}})['then'](function(_0x4a2c49){if(_0x4a2c49){_0x2f8abc[_0x4b56('0x82')][_0x4b56('0x99')]({'id':0x0,'priority':0x0,'app':_0x4b56('0x9a'),'appdata':_0x4a2c49['name']+','+(_0x2f8abc[_0x4b56('0x86')][_0x4b56('0x9b')]||0xa),'interval':_0x4b56('0x96')});_0x2f8abc[_0x4b56('0x9c')]=![];}return respondWithRpcPromise(_0x4b56('0x9d'),'startRouting',_0x2f8abc);});}return respondWithRpcPromise(_0x4b56('0x9d'),'startRouting',_0x2f8abc);})['then'](function(_0x36f85e){respondWithRpcPromise('EventManager',_0x4b56('0x9e'),{'event':_0x4b56('0x9f'),'message':_0x36f85e},client9002);return _0x36f85e;})[_0x4b56('0x24')](respondWithResult(_0x1def43,null))[_0x4b56('0x2b')](handleError(_0x1def43,null));};exports['addApplications']=function(_0xf64a26,_0x5da08a,_0x3f3973){return db[_0x4b56('0x40')]['findOne']({'where':{'id':_0xf64a26[_0x4b56('0x58')]['id']}})['then'](handleEntityNotFound(_0x5da08a,null))[_0x4b56('0x24')](function(_0x330922){if(_0x330922){return db[_0x4b56('0xa0')][_0x4b56('0xa1')](function(_0x100c30){return db[_0x4b56('0x81')]['destroy']({'where':{'OpenchannelAccountId':_0xf64a26[_0x4b56('0x58')]['id']},'transaction':_0x100c30})[_0x4b56('0x24')](function(_0x3257ae){var _0x51b2de=_['map'](_0xf64a26['body'],function(_0x2b6ba1){_0x2b6ba1[_0x4b56('0x6a')]=_0xf64a26[_0x4b56('0x58')]['id'];return _0x2b6ba1;});return db['OpenchannelApplication'][_0x4b56('0xa2')](_0x51b2de,{'transaction':_0x100c30});});})[_0x4b56('0x24')](function(){return db[_0x4b56('0x81')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0xf64a26[_0x4b56('0x58')]['id']},'order':_0x4b56('0x84')});});}})[_0x4b56('0x24')](respondWithResult(_0x5da08a,null))[_0x4b56('0x2b')](handleError(_0x5da08a,null));};exports[_0x4b56('0xa3')]=function(_0x4668c1,_0x5519a7,_0x6c2522){var _0x592144={};var _0x3d41ca={};var _0x531733;var _0xd6a839;return db[_0x4b56('0x40')][_0x4b56('0xa4')]({'where':{'id':_0x4668c1[_0x4b56('0x58')]['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x5519a7,null))[_0x4b56('0x24')](function(_0x369cc3){if(_0x369cc3){_0x531733=_0x369cc3;_0x3d41ca[_0x4b56('0x44')]=_[_0x4b56('0x46')](db[_0x4b56('0x81')][_0x4b56('0x41')]);_0x3d41ca['query']=_[_0x4b56('0x46')](_0x4668c1[_0x4b56('0x45')]);_0x3d41ca[_0x4b56('0x50')]=_[_0x4b56('0x47')](_0x3d41ca['model'],_0x3d41ca[_0x4b56('0x45')]);_0x592144[_0x4b56('0x48')]=_[_0x4b56('0x47')](_0x3d41ca[_0x4b56('0x44')],qs['fields'](_0x4668c1[_0x4b56('0x45')]['fields']));_0x592144[_0x4b56('0x48')]=_0x592144['attributes']['length']?_0x592144[_0x4b56('0x48')]:_0x3d41ca['model'];_0x592144[_0x4b56('0x4e')]=qs[_0x4b56('0x4f')](_0x4668c1[_0x4b56('0x45')][_0x4b56('0x4f')]);_0x592144['where']=qs[_0x4b56('0x50')](_['pick'](_0x4668c1[_0x4b56('0x45')],_0x3d41ca['filters']));if(_0x4668c1[_0x4b56('0x45')]['filter']){_0x592144[_0x4b56('0x52')]=_[_0x4b56('0x53')](_0x592144[_0x4b56('0x52')],{'$or':_['map'](_0x592144[_0x4b56('0x48')],function(_0x2899f1){var _0x3a0781={};_0x3a0781[_0x2899f1]={'$like':'%'+_0x4668c1[_0x4b56('0x45')]['filter']+'%'};return _0x3a0781;})});}_0x592144=_[_0x4b56('0x53')]({},_0x592144,_0x4668c1[_0x4b56('0x5b')]);return _0x531733[_0x4b56('0xa3')](_0x592144);}})[_0x4b56('0x24')](function(_0x5229ef){if(_0x5229ef){_0xd6a839=_0x5229ef['length'];if(!_0x4668c1[_0x4b56('0x45')][_0x4b56('0x4b')](_0x4b56('0x4c'))){_0x592144[_0x4b56('0x4d')]=qs['limit'](_0x4668c1['query'][_0x4b56('0x4d')]);_0x592144[_0x4b56('0x2f')]=qs['offset'](_0x4668c1[_0x4b56('0x45')][_0x4b56('0x2f')]);}return _0x531733[_0x4b56('0xa3')](_0x592144);}})[_0x4b56('0x24')](function(_0x1b9c9c){if(_0x1b9c9c){return _0x1b9c9c?{'count':_0xd6a839,'rows':_0x1b9c9c}:null;}})[_0x4b56('0x24')](respondWithResult(_0x5519a7,null))['catch'](handleError(_0x5519a7,null));};exports[_0x4b56('0xa5')]=function(_0x4fe963,_0x14fc88,_0x58e4fc){var _0x41e667={'raw':![],'where':{}};var _0x1b01ed={};var _0x433376={'count':0x0,'rows':[]};return db[_0x4b56('0x40')][_0x4b56('0xa4')]({'where':{'id':_0x4fe963[_0x4b56('0x58')]['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x14fc88,null))['then'](function(_0x21e752){if(_0x21e752){_0x1b01ed[_0x4b56('0x44')]=_[_0x4b56('0x46')](db['OpenchannelInteraction'][_0x4b56('0x41')]);_0x1b01ed[_0x4b56('0x45')]=_[_0x4b56('0x46')](_0x4fe963[_0x4b56('0x45')]);_0x1b01ed[_0x4b56('0x50')]=_[_0x4b56('0x47')](_0x1b01ed[_0x4b56('0x44')],_0x1b01ed[_0x4b56('0x45')]);_0x41e667[_0x4b56('0x48')]=_[_0x4b56('0x47')](_0x1b01ed[_0x4b56('0x44')],qs[_0x4b56('0x49')](_0x4fe963[_0x4b56('0x45')][_0x4b56('0x49')]));_0x41e667[_0x4b56('0x48')]=_0x41e667['attributes'][_0x4b56('0x4a')]?_0x41e667[_0x4b56('0x48')]:_0x1b01ed[_0x4b56('0x44')];if(!_0x4fe963[_0x4b56('0x45')]['hasOwnProperty']('nolimit')){_0x41e667[_0x4b56('0x4d')]=qs[_0x4b56('0x4d')](_0x4fe963['query']['limit']);_0x41e667[_0x4b56('0x2f')]=qs[_0x4b56('0x2f')](_0x4fe963[_0x4b56('0x45')][_0x4b56('0x2f')]);}_0x41e667['order']=qs[_0x4b56('0x4f')](_0x4fe963[_0x4b56('0x45')][_0x4b56('0x4f')]);_0x41e667[_0x4b56('0x52')]=qs['filters'](_[_0x4b56('0x51')](_0x4fe963['query'],_0x1b01ed['filters']));_0x41e667[_0x4b56('0x52')][_0x4b56('0x6a')]=_0x21e752['id'];if(_0x4fe963[_0x4b56('0x45')]['filter']){_0x41e667[_0x4b56('0x52')]=_[_0x4b56('0x53')](_0x41e667[_0x4b56('0x52')],{'$or':_[_0x4b56('0x3f')](_0x41e667[_0x4b56('0x48')],function(_0x3c2adc){var _0x2b7d13={};_0x2b7d13[_0x3c2adc]={'$like':'%'+_0x4fe963[_0x4b56('0x45')]['filter']+'%'};return _0x2b7d13;})});}_0x41e667=_[_0x4b56('0x53')]({},_0x41e667,_0x4fe963[_0x4b56('0x5b')]);return db[_0x4b56('0x8c')]['count']({'where':_0x41e667[_0x4b56('0x52')]})[_0x4b56('0x24')](function(_0xa97bb8){_0x433376[_0x4b56('0x2e')]=_0xa97bb8;if(_0x4fe963[_0x4b56('0x45')][_0x4b56('0x5a')]){_0x41e667[_0x4b56('0x56')]=[{'model':db[_0x4b56('0x72')],'as':_0x4b56('0xa6'),'required':![]},{'model':db['User'],'as':'Owner','attributes':[_0x4b56('0x3b'),'fullname','internal'],'required':![]},{'model':db[_0x4b56('0xa7')],'as':_0x4b56('0xa8'),'attributes':['id',_0x4b56('0x3b'),'color'],'where':_0x4fe963[_0x4b56('0x45')]['tag']?{'id':_0x4fe963[_0x4b56('0x45')][_0x4b56('0xa9')]}:undefined,'required':_0x4fe963[_0x4b56('0x45')][_0x4b56('0xa9')]?!![]:![]}];}return db[_0x4b56('0x8c')][_0x4b56('0x6b')](_0x41e667);})[_0x4b56('0x24')](function(_0x308d08){_0x433376[_0x4b56('0x6c')]=_0x308d08;return _0x433376;});}})[_0x4b56('0x24')](respondWithFilteredResult(_0x14fc88,_0x41e667))[_0x4b56('0x2b')](handleError(_0x14fc88,null));};exports['addAgents']=function(_0x304678,_0x25c055,_0x3efa60){return db[_0x4b56('0x40')][_0x4b56('0x5c')]({'where':{'id':_0x304678[_0x4b56('0x58')]['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x25c055,null))[_0x4b56('0x24')](function(_0x4a3508){if(_0x4a3508){return _0x4a3508[_0x4b56('0xaa')](_0x304678['body']['ids'],_['omit'](_0x304678[_0x4b56('0x5e')],[_0x4b56('0x6e'),'id'])||{})[_0x4b56('0x8e')](function(_0x19e344){for(var _0x5a5dd9=0x0;_0x5a5dd9<_0x304678[_0x4b56('0x5e')]['ids'][_0x4b56('0x4a')];_0x5a5dd9+=0x1){socket[_0x4b56('0xab')](_0x4b56('0xac'),{'UserId':_0x304678[_0x4b56('0x5e')]['ids'][_0x5a5dd9],'OpenchannelAccountId':_0x304678['params']['id']});}return _0x19e344;});}})[_0x4b56('0x24')](respondWithResult(_0x25c055,null))['catch'](handleError(_0x25c055,null));};exports[_0x4b56('0xad')]=function(_0x229557,_0x43f752,_0x51d026){return db['OpenchannelAccount'][_0x4b56('0x5c')]({'where':{'id':_0x229557[_0x4b56('0x58')]['id']}})[_0x4b56('0x24')](handleEntityNotFound(_0x43f752,null))[_0x4b56('0x24')](function(_0x5cdb38){if(_0x5cdb38){return _0x5cdb38[_0x4b56('0xad')](_0x229557[_0x4b56('0x45')][_0x4b56('0x6e')])[_0x4b56('0x24')](function(){if(_[_0x4b56('0xae')](_0x229557[_0x4b56('0x45')]['ids'])){for(var _0x2b42c0=0x0;_0x2b42c0<_0x229557[_0x4b56('0x45')][_0x4b56('0x6e')][_0x4b56('0x4a')];_0x2b42c0+=0x1){socket['emit'](_0x4b56('0xaf'),{'UserId':Number(_0x229557[_0x4b56('0x45')][_0x4b56('0x6e')][_0x2b42c0]),'OpenchannelAccountId':Number(_0x229557[_0x4b56('0x58')]['id'])});}}else{socket['emit'](_0x4b56('0xaf'),{'UserId':Number(_0x229557[_0x4b56('0x45')][_0x4b56('0x6e')]),'OpenchannelAccountId':Number(_0x229557[_0x4b56('0x58')]['id'])});}});}})[_0x4b56('0x24')](respondWithStatusCode(_0x43f752,null))[_0x4b56('0x2b')](handleError(_0x43f752,null));};exports['getAgents']=function(_0x214ea0,_0x4d47d2,_0x2f4a38){var _0x3ac113={};var _0x4cc8b7={};var _0x377d97;var _0x2cd993;return db[_0x4b56('0x40')][_0x4b56('0xa4')]({'where':{'id':_0x214ea0[_0x4b56('0x58')]['id']}})['then'](handleEntityNotFound(_0x4d47d2,null))['then'](function(_0x33239d){if(_0x33239d){_0x377d97=_0x33239d;_0x4cc8b7[_0x4b56('0x44')]=_[_0x4b56('0x46')](db['User']['rawAttributes']);_0x4cc8b7['query']=_['keys'](_0x214ea0[_0x4b56('0x45')]);_0x4cc8b7['filters']=_[_0x4b56('0x47')](_0x4cc8b7[_0x4b56('0x44')],_0x4cc8b7[_0x4b56('0x45')]);_0x3ac113[_0x4b56('0x48')]=_[_0x4b56('0x47')](_0x4cc8b7[_0x4b56('0x44')],qs[_0x4b56('0x49')](_0x214ea0['query']['fields']));_0x3ac113[_0x4b56('0x48')]=_0x3ac113[_0x4b56('0x48')]['length']?_0x3ac113[_0x4b56('0x48')]:_0x4cc8b7[_0x4b56('0x44')];_0x3ac113[_0x4b56('0x4e')]=qs[_0x4b56('0x4f')](_0x214ea0[_0x4b56('0x45')][_0x4b56('0x4f')]);_0x3ac113['where']=qs[_0x4b56('0x50')](_['pick'](_0x214ea0[_0x4b56('0x45')],_0x4cc8b7[_0x4b56('0x50')]));if(_0x214ea0[_0x4b56('0x45')]['filter']){_0x3ac113['where']=_[_0x4b56('0x53')](_0x3ac113[_0x4b56('0x52')],{'$or':_[_0x4b56('0x3f')](_0x3ac113['attributes'],function(_0x1dc387){var _0x8d5edc={};_0x8d5edc[_0x1dc387]={'$like':'%'+_0x214ea0[_0x4b56('0x45')]['filter']+'%'};return _0x8d5edc;})});}_0x3ac113=_[_0x4b56('0x53')]({},_0x3ac113,_0x214ea0[_0x4b56('0x5b')]);return _0x377d97[_0x4b56('0xb0')](_0x3ac113);}})[_0x4b56('0x24')](function(_0x251347){if(_0x251347){_0x2cd993=_0x251347[_0x4b56('0x4a')];if(!_0x214ea0[_0x4b56('0x45')][_0x4b56('0x4b')]('nolimit')){_0x3ac113[_0x4b56('0x4d')]=qs[_0x4b56('0x4d')](_0x214ea0[_0x4b56('0x45')][_0x4b56('0x4d')]);_0x3ac113[_0x4b56('0x2f')]=qs['offset'](_0x214ea0[_0x4b56('0x45')]['offset']);}return _0x377d97['getAgents'](_0x3ac113);}})[_0x4b56('0x24')](function(_0x24345d){if(_0x24345d){return _0x24345d?{'count':_0x2cd993,'rows':_0x24345d}:null;}})[_0x4b56('0x24')](respondWithResult(_0x4d47d2,null))['catch'](handleError(_0x4d47d2,null));};exports['send']=function(_0x225906,_0x424611,_0x51a8b6){var _0x1e3788,_0x16fb8,_0x13c10f;if(_[_0x4b56('0x78')](_0x225906[_0x4b56('0x5e')]['body'])||_0x225906[_0x4b56('0x5e')]['body']===''){throw new db[(_0x4b56('0x20'))][(_0x4b56('0x21'))](_0x4b56('0x7b'));}if(_[_0x4b56('0x78')](_0x225906[_0x4b56('0x5e')]['to'])){}_0x1e3788=_0x225906['body']['to'];return db['OpenchannelAccount'][_0x4b56('0xa4')]({'where':{'id':_0x225906[_0x4b56('0x58')]['id']}})['then'](handleEntityNotFound(_0x424611,null))[_0x4b56('0x24')](function(_0x5d4ba1){if(_0x5d4ba1){return db[_0x4b56('0x40')]['find']({'where':{'id':_0x5d4ba1['id']},'include':[{'model':db[_0x4b56('0x7e')],'as':_0x4b56('0x7f'),'include':[{'model':db[_0x4b56('0x72')],'as':_0x4b56('0x80'),'where':{[_0x5d4ba1[_0x4b56('0x7d')]]:_0x1e3788},'limit':0x1,'order':[[_0x4b56('0x75'),_0x4b56('0xb1')]]}]}]})[_0x4b56('0x24')](handleEntityNotFound(_0x424611,null))[_0x4b56('0x24')](function(_0x3071e5){if(_0x3071e5&&_0x3071e5[_0x4b56('0x7f')]){_0x16fb8=_0x3071e5[_0x4b56('0x36')]({'plain':!![]});if(_0x16fb8[_0x4b56('0x7f')]&&_0x16fb8[_0x4b56('0x7f')][_0x4b56('0x80')][_0x4b56('0x4a')]){return _0x16fb8[_0x4b56('0x7f')][_0x4b56('0x80')][0x0];}return db['CmContact'][_0x4b56('0x5d')](_[_0x4b56('0x19')](_0x225906['body'],{'firstName':_0x1e3788,[_0x3071e5[_0x4b56('0x7d')]]:_0x1e3788,'phone':_0x1e3788,'ListId':_0x16fb8[_0x4b56('0x77')]}));}})[_0x4b56('0x24')](handleEntityNotFound(_0x424611,null))[_0x4b56('0x24')](function(_0x7f752e){if(_0x7f752e){_0x13c10f=_0x7f752e;return db[_0x4b56('0x8c')][_0x4b56('0x5c')]({'where':{'ContactId':_0x13c10f['id'],'closed':![],'OpenchannelAccountId':_0x16fb8['id']}})[_0x4b56('0x24')](function(_0x28e28e){if(_0x28e28e){return[_0x28e28e,![]];}return db[_0x4b56('0x8c')][_0x4b56('0x5d')]({'UserId':_0x225906[_0x4b56('0x61')]['id'],'ContactId':_0x13c10f['id'],'OpenchannelAccountId':_0x16fb8['id'],'lastMsgDirection':_0x4b56('0xb2'),'Messages':[_[_0x4b56('0x53')](_0x225906[_0x4b56('0x5e')],{'read':![],'body':_0x225906[_0x4b56('0x5e')][_0x4b56('0x5e')],'OpenchannelAccountId':_0x16fb8['id'],'UserId':_0x225906['user']['id'],'ContactId':_0x13c10f['id']})]},{'include':[{'model':db['OpenchannelMessage'],'as':_0x4b56('0xb3')}]})[_0x4b56('0x24')](function(_0x1aac47){return[_0x1aac47,!![]];});});}})[_0x4b56('0x8e')](function(_0xb6b792,_0x1ba6af){if(_0x1ba6af){return _0xb6b792;}return db['OpenchannelMessage'][_0x4b56('0x5d')](_[_0x4b56('0x53')](_0x225906[_0x4b56('0x5e')],{'read':![],'body':_0x225906[_0x4b56('0x5e')][_0x4b56('0x5e')],'OpenchannelAccountId':_0x16fb8['id'],'OpenchannelInteractionId':_0xb6b792['id'],'UserId':_0x225906['user']['id'],'ContactId':_0x13c10f['id']}))['then'](function(_0x404f57){_0xb6b792[_0x4b56('0xb4')]['Messages']=[];_0xb6b792['dataValues'][_0x4b56('0xb3')][_0x4b56('0xb5')](_0x404f57[_0x4b56('0xb4')]);return _0xb6b792;});});}})[_0x4b56('0x24')](respondWithResult(_0x424611,null))['catch'](handleError(_0x424611,null));};
\ No newline at end of file
+var _0x98f9=['error','OpenchannelAccount,\x20%s,\x20%s','message','catch','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','OpenchannelAccounts','UserProfileResource','end','sendStatus','name','index','Pause','mandatoryDispositionPause','map','OpenchannelAccount','fieldName','type','model','query','filters','attributes','fields','hasOwnProperty','nolimit','order','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','show','params','keys','intersection','length','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','find','Disposition','getDispositions','findOne','rawAttributes','sort','OpenchannelAccountId','rows','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','notify','openchannel','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','includes','mapKey','CmContact','Contacts','DESC','Applications','List','account','applications','list','orderBy','ListId','contact','firstName','lastName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','messageId','interaction','created','autoclose','push','unmanaged','OpenchannelMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','addApplications','sequelize','transaction','OpenchannelApplication','bulkCreate','priority','getApplications','Contact','Owner','fullname','Tag','Tags','addAgents','omit','emit','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','send','CmList','Messages','dataValues','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./openchannelAccount.socket','register','jayson/promise','client','http','request','then','request\x20sent','stringify'];(function(_0x2f0b26,_0x5bae04){var _0x5aa5c6=function(_0x1d81e0){while(--_0x1d81e0){_0x2f0b26['push'](_0x2f0b26['shift']());}};_0x5aa5c6(++_0x5bae04);}(_0x98f9,0x150));var _0x998f=function(_0x3a2721,_0x10f711){_0x3a2721=_0x3a2721-0x0;var _0x33be8d=_0x98f9[_0x3a2721];return _0x33be8d;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x998f('0x0'));var rimraf=require(_0x998f('0x1'));var zipdir=require(_0x998f('0x2'));var jsonpatch=require(_0x998f('0x3'));var rp=require(_0x998f('0x4'));var moment=require('moment');var BPromise=require(_0x998f('0x5'));var Mustache=require(_0x998f('0x6'));var util=require(_0x998f('0x7'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x998f('0x8'));var squel=require(_0x998f('0x9'));var crypto=require(_0x998f('0xa'));var jsforce=require(_0x998f('0xb'));var deskjs=require(_0x998f('0xc'));var toCsv=require(_0x998f('0xd'));var querystring=require(_0x998f('0xe'));var Papa=require(_0x998f('0xf'));var Redis=require(_0x998f('0x10'));var authService=require(_0x998f('0x11'));var qs=require(_0x998f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x998f('0x13'))(_0x998f('0x14'));var utils=require(_0x998f('0x15'));var config=require(_0x998f('0x16'));var licenseUtil=require(_0x998f('0x17'));var db=require(_0x998f('0x18'))['db'];config['redis']=_[_0x998f('0x19')](config['redis'],{'host':_0x998f('0x1a'),'port':0x18eb});var socket=require(_0x998f('0x1b'))(new Redis(config[_0x998f('0x1c')]));require(_0x998f('0x1d'))[_0x998f('0x1e')](socket);var jayson=require(_0x998f('0x1f'));var client=jayson[_0x998f('0x20')][_0x998f('0x21')]({'port':0x232c});var client9002=jayson['client'][_0x998f('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x1a8be6,_0x477b10,_0x553597,_0x1c677e){return new BPromise(function(_0x256335,_0x28bb5a){var _0x28eac3=_0x1c677e||client;return _0x28eac3[_0x998f('0x22')](_0x1a8be6,_0x553597)[_0x998f('0x23')](function(_0x13081f){logger['info']('OpenchannelAccount,\x20%s,\x20%s',_0x477b10,'request\x20sent');logger['debug']('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0x477b10,_0x998f('0x24'),JSON[_0x998f('0x25')](_0x13081f));if(_0x13081f[_0x998f('0x26')]){if(_0x13081f[_0x998f('0x26')]['code']===0x1f4){logger[_0x998f('0x26')](_0x998f('0x27'),_0x477b10,_0x13081f[_0x998f('0x26')][_0x998f('0x28')]);return _0x28bb5a(_0x13081f['error'][_0x998f('0x28')]);}logger[_0x998f('0x26')](_0x998f('0x27'),_0x477b10,_0x13081f[_0x998f('0x26')][_0x998f('0x28')]);return _0x256335(_0x13081f['error'][_0x998f('0x28')]);}else{logger['info'](_0x998f('0x27'),_0x477b10,'request\x20sent');_0x256335(_0x13081f['result'][_0x998f('0x28')]);}})[_0x998f('0x29')](function(_0x2699ce){logger[_0x998f('0x26')]('OpenchannelAccount,\x20%s,\x20%s',_0x477b10,_0x2699ce);_0x28bb5a(_0x2699ce);});});}function respondWithStatusCode(_0x2fd371,_0x10cdc2){_0x10cdc2=_0x10cdc2||0xcc;return function(_0x61fe57){if(_0x61fe57){return _0x2fd371['sendStatus'](_0x10cdc2);}return _0x2fd371[_0x998f('0x2a')](_0x10cdc2)['end']();};}function respondWithResult(_0x4a43a7,_0x592c0b){_0x592c0b=_0x592c0b||0xc8;return function(_0x52c539){if(_0x52c539){return _0x4a43a7[_0x998f('0x2a')](_0x592c0b)[_0x998f('0x2b')](_0x52c539);}};}function respondWithFilteredResult(_0x176774,_0x56cb29){return function(_0x182259){if(_0x182259){var _0x78e261=_0x182259[_0x998f('0x2c')],_0x1ac57e=_0x56cb29[_0x998f('0x2d')],_0x47fd98=_0x56cb29['offset']+_0x56cb29[_0x998f('0x2e')],_0x4a141a;if(_0x47fd98>=_0x78e261){_0x47fd98=_0x78e261;_0x4a141a=0xc8;}else{_0x4a141a=0xce;}_0x176774[_0x998f('0x2a')](_0x4a141a);return _0x176774[_0x998f('0x2f')](_0x998f('0x30'),_0x1ac57e+'-'+_0x47fd98+'/'+_0x78e261)[_0x998f('0x2b')](_0x182259);}return null;};}function patchUpdates(_0x14d99b){return function(_0x1c7755){try{jsonpatch[_0x998f('0x31')](_0x1c7755,_0x14d99b,!![]);}catch(_0x2b8ae0){return BPromise[_0x998f('0x32')](_0x2b8ae0);}return _0x1c7755[_0x998f('0x33')]();};}function saveUpdates(_0x43cb26,_0x464cfb){return function(_0x3ad1ad){if(_0x3ad1ad){return _0x3ad1ad[_0x998f('0x34')](_0x43cb26)['then'](function(_0xcb7823){return _0xcb7823;});}return null;};}function removeEntity(_0x3c59f3,_0x1835bc){return function(_0x4042e7){if(_0x4042e7){return _0x4042e7[_0x998f('0x35')]()[_0x998f('0x23')](function(){var _0x13a4eb=_0x4042e7['get']({'plain':!![]});var _0x4328e7=_0x998f('0x36');return db[_0x998f('0x37')][_0x998f('0x35')]({'where':{'type':_0x4328e7,'resourceId':_0x13a4eb['id']}})[_0x998f('0x23')](function(){return _0x4042e7;});})['then'](function(){_0x3c59f3[_0x998f('0x2a')](0xcc)[_0x998f('0x38')]();});}};}function handleEntityNotFound(_0xcae573,_0x4bf7d5){return function(_0x3b556c){if(!_0x3b556c){_0xcae573[_0x998f('0x39')](0x194);}return _0x3b556c;};}function handleError(_0x40f08b,_0x2aa431){_0x2aa431=_0x2aa431||0x1f4;return function(_0x4c930b){logger['error'](_0x4c930b['stack']);if(_0x4c930b[_0x998f('0x3a')]){delete _0x4c930b[_0x998f('0x3a')];}_0x40f08b[_0x998f('0x2a')](_0x2aa431)['send'](_0x4c930b);};}exports[_0x998f('0x3b')]=function(_0x385f5c,_0x5004de){var _0x58a6f4={'include':[{'model':db[_0x998f('0x3c')],'as':_0x998f('0x3d')}]},_0x146641={},_0x309ff4={'count':0x0,'rows':[]};var _0x34cdc9=_[_0x998f('0x3e')](db[_0x998f('0x3f')]['rawAttributes'],function(_0x3fb8ec){return{'name':_0x3fb8ec[_0x998f('0x40')],'type':_0x3fb8ec[_0x998f('0x41')]['key']};});_0x146641[_0x998f('0x42')]=_[_0x998f('0x3e')](_0x34cdc9,_0x998f('0x3a'));_0x146641[_0x998f('0x43')]=_['keys'](_0x385f5c[_0x998f('0x43')]);_0x146641[_0x998f('0x44')]=_['intersection'](_0x146641['model'],_0x146641[_0x998f('0x43')]);_0x58a6f4[_0x998f('0x45')]=_['intersection'](_0x146641[_0x998f('0x42')],qs[_0x998f('0x46')](_0x385f5c[_0x998f('0x43')]['fields']));_0x58a6f4[_0x998f('0x45')]=_0x58a6f4[_0x998f('0x45')]['length']?_0x58a6f4[_0x998f('0x45')]:_0x146641['model'];if(!_0x385f5c[_0x998f('0x43')][_0x998f('0x47')](_0x998f('0x48'))){_0x58a6f4['limit']=qs['limit'](_0x385f5c[_0x998f('0x43')][_0x998f('0x2e')]);_0x58a6f4[_0x998f('0x2d')]=qs[_0x998f('0x2d')](_0x385f5c[_0x998f('0x43')][_0x998f('0x2d')]);}_0x58a6f4[_0x998f('0x49')]=qs['sort'](_0x385f5c[_0x998f('0x43')]['sort']);_0x58a6f4[_0x998f('0x4a')]=qs[_0x998f('0x44')](_[_0x998f('0x4b')](_0x385f5c[_0x998f('0x43')],_0x146641[_0x998f('0x44')]),_0x34cdc9);if(_0x385f5c[_0x998f('0x43')][_0x998f('0x4c')]){_0x58a6f4['where']=_['merge'](_0x58a6f4['where'],{'$or':_[_0x998f('0x3e')](_0x34cdc9,function(_0x48c4c7){if(_0x48c4c7[_0x998f('0x41')]!==_0x998f('0x4d')){var _0x4376c7={};_0x4376c7[_0x48c4c7[_0x998f('0x3a')]]={'$like':'%'+_0x385f5c[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x4376c7;}})});}_0x58a6f4=_[_0x998f('0x4e')]({},_0x58a6f4,_0x385f5c[_0x998f('0x4f')]);var _0x1326df={'where':_0x58a6f4[_0x998f('0x4a')]};return db[_0x998f('0x3f')][_0x998f('0x2c')](_0x1326df)[_0x998f('0x23')](function(_0x58952d){_0x309ff4[_0x998f('0x2c')]=_0x58952d;if(_0x385f5c['query'][_0x998f('0x50')]){_0x58a6f4[_0x998f('0x51')]=[{'all':!![]}];}return db[_0x998f('0x3f')][_0x998f('0x52')](_0x58a6f4);})['then'](function(_0x529815){_0x309ff4['rows']=_0x529815;return _0x309ff4;})[_0x998f('0x23')](respondWithFilteredResult(_0x5004de,_0x58a6f4))['catch'](handleError(_0x5004de,null));};exports[_0x998f('0x53')]=function(_0x55b16d,_0x2dadac){var _0x2ba0e6={'raw':![],'where':{'id':_0x55b16d[_0x998f('0x54')]['id']},'include':[{'model':db[_0x998f('0x3c')],'as':'mandatoryDispositionPause'}]},_0x204c19={};_0x204c19['model']=_[_0x998f('0x55')](db['OpenchannelAccount']['rawAttributes']);_0x204c19['query']=_[_0x998f('0x55')](_0x55b16d['query']);_0x204c19['filters']=_[_0x998f('0x56')](_0x204c19['model'],_0x204c19['query']);_0x2ba0e6[_0x998f('0x45')]=_[_0x998f('0x56')](_0x204c19[_0x998f('0x42')],qs[_0x998f('0x46')](_0x55b16d['query'][_0x998f('0x46')]));_0x2ba0e6[_0x998f('0x45')]=_0x2ba0e6[_0x998f('0x45')][_0x998f('0x57')]?_0x2ba0e6[_0x998f('0x45')]:_0x204c19['model'];if(_0x55b16d[_0x998f('0x43')][_0x998f('0x50')]){_0x2ba0e6[_0x998f('0x51')]=[{'all':!![]}];}_0x2ba0e6=_[_0x998f('0x4e')]({},_0x2ba0e6,_0x55b16d[_0x998f('0x4f')]);return db[_0x998f('0x3f')]['find'](_0x2ba0e6)[_0x998f('0x23')](handleEntityNotFound(_0x2dadac,null))[_0x998f('0x23')](respondWithResult(_0x2dadac,null))[_0x998f('0x29')](handleError(_0x2dadac,null));};exports[_0x998f('0x58')]=function(_0x424377,_0x4bee9e){return db[_0x998f('0x3f')][_0x998f('0x58')](_0x424377[_0x998f('0x59')],{})[_0x998f('0x23')](function(_0x1b063d){var _0x11221b=_0x424377[_0x998f('0x5a')][_0x998f('0x5b')]({'plain':!![]});if(!_0x11221b)throw new Error(_0x998f('0x5c'));if(_0x11221b[_0x998f('0x5d')]===_0x998f('0x5a')){var _0x3c688e=_0x1b063d[_0x998f('0x5b')]({'plain':!![]});var _0x51ac52='OpenchannelAccounts';return db[_0x998f('0x5e')]['find']({'where':{'name':_0x51ac52,'userProfileId':_0x11221b[_0x998f('0x5f')]},'raw':!![]})['then'](function(_0x1b51cb){if(_0x1b51cb&&_0x1b51cb[_0x998f('0x60')]===0x0){return db[_0x998f('0x37')]['create']({'name':_0x3c688e[_0x998f('0x3a')],'resourceId':_0x3c688e['id'],'type':_0x1b51cb['name'],'sectionId':_0x1b51cb['id']},{})[_0x998f('0x23')](function(){return _0x1b063d;});}else{return _0x1b063d;}})[_0x998f('0x29')](function(_0x209bc2){logger[_0x998f('0x26')](_0x998f('0x61'),_0x209bc2);throw _0x209bc2;});}return _0x1b063d;})[_0x998f('0x23')](respondWithResult(_0x4bee9e,0xc9))[_0x998f('0x29')](handleError(_0x4bee9e,null));};exports[_0x998f('0x34')]=function(_0x3bc4aa,_0x2c0b3b){if(_0x3bc4aa[_0x998f('0x59')]['id']){delete _0x3bc4aa[_0x998f('0x59')]['id'];}return db['OpenchannelAccount']['find']({'where':{'id':_0x3bc4aa[_0x998f('0x54')]['id']},'include':[{'model':db[_0x998f('0x3c')],'as':'mandatoryDispositionPause'}]})[_0x998f('0x23')](handleEntityNotFound(_0x2c0b3b,null))[_0x998f('0x23')](saveUpdates(_0x3bc4aa['body'],null))[_0x998f('0x23')](respondWithResult(_0x2c0b3b,null))[_0x998f('0x29')](handleError(_0x2c0b3b,null));};exports[_0x998f('0x35')]=function(_0x4890fb,_0x3f70a7){return db[_0x998f('0x3f')]['find']({'where':{'id':_0x4890fb[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x3f70a7,null))[_0x998f('0x23')](removeEntity(_0x3f70a7,null))[_0x998f('0x29')](handleError(_0x3f70a7,null));};exports[_0x998f('0x62')]=function(_0x2d70f3,_0x49e298){return db[_0x998f('0x3f')][_0x998f('0x62')]()[_0x998f('0x23')](respondWithResult(_0x49e298,null))[_0x998f('0x29')](handleError(_0x49e298,null));};exports['addDisposition']=function(_0x1c07df,_0x4d8f7a,_0x190927){if(_0x1c07df['body']['id']){delete _0x1c07df[_0x998f('0x59')]['id'];}return db[_0x998f('0x3f')][_0x998f('0x63')]({'where':{'id':_0x1c07df[_0x998f('0x54')]['id']}})['then'](handleEntityNotFound(_0x4d8f7a,null))[_0x998f('0x23')](function(_0x441eb9){if(_0x441eb9){_0x1c07df['body']['OpenchannelAccountId']=_0x441eb9['id'];return db[_0x998f('0x64')][_0x998f('0x58')](_0x1c07df[_0x998f('0x59')]);}})[_0x998f('0x23')](respondWithResult(_0x4d8f7a,null))[_0x998f('0x29')](handleError(_0x4d8f7a,null));};exports[_0x998f('0x65')]=function(_0x20de63,_0x21a2e8,_0x289986){var _0x91d6f8={'raw':![],'where':{}};var _0x6f2b91={};var _0x3ad445={'count':0x0,'rows':[]};return db[_0x998f('0x3f')][_0x998f('0x66')]({'where':{'id':_0x20de63[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x21a2e8,null))[_0x998f('0x23')](function(_0x14f241){if(_0x14f241){_0x6f2b91[_0x998f('0x42')]=_[_0x998f('0x55')](db[_0x998f('0x64')][_0x998f('0x67')]);_0x6f2b91['query']=_[_0x998f('0x55')](_0x20de63[_0x998f('0x43')]);_0x6f2b91[_0x998f('0x44')]=_[_0x998f('0x56')](_0x6f2b91['model'],_0x6f2b91['query']);_0x91d6f8[_0x998f('0x45')]=_[_0x998f('0x56')](_0x6f2b91[_0x998f('0x42')],qs['fields'](_0x20de63['query'][_0x998f('0x46')]));_0x91d6f8[_0x998f('0x45')]=_0x91d6f8[_0x998f('0x45')][_0x998f('0x57')]?_0x91d6f8['attributes']:_0x6f2b91[_0x998f('0x42')];if(!_0x20de63[_0x998f('0x43')][_0x998f('0x47')]('nolimit')){_0x91d6f8[_0x998f('0x2e')]=qs['limit'](_0x20de63['query']['limit']);_0x91d6f8[_0x998f('0x2d')]=qs['offset'](_0x20de63[_0x998f('0x43')][_0x998f('0x2d')]);}_0x91d6f8[_0x998f('0x49')]=qs[_0x998f('0x68')](_0x20de63['query']['sort']);_0x91d6f8[_0x998f('0x4a')]=qs[_0x998f('0x44')](_[_0x998f('0x4b')](_0x20de63[_0x998f('0x43')],_0x6f2b91[_0x998f('0x44')]));_0x91d6f8['where'][_0x998f('0x69')]=_0x14f241['id'];if(_0x20de63[_0x998f('0x43')][_0x998f('0x4c')]){_0x91d6f8[_0x998f('0x4a')]=_[_0x998f('0x4e')](_0x91d6f8[_0x998f('0x4a')],{'$or':_[_0x998f('0x3e')](_0x91d6f8['attributes'],function(_0x29dd1d){var _0x199a50={};_0x199a50[_0x29dd1d]={'$like':'%'+_0x20de63[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x199a50;})});}_0x91d6f8=_[_0x998f('0x4e')]({},_0x91d6f8,_0x20de63['options']);return db[_0x998f('0x64')]['count']({'where':_0x91d6f8[_0x998f('0x4a')]})[_0x998f('0x23')](function(_0x5b2d81){_0x3ad445['count']=_0x5b2d81;if(_0x20de63[_0x998f('0x43')][_0x998f('0x50')]){_0x91d6f8[_0x998f('0x51')]=[{'all':!![]}];}return db['Disposition']['findAll'](_0x91d6f8);})[_0x998f('0x23')](function(_0x762167){_0x3ad445[_0x998f('0x6a')]=_0x762167;return _0x3ad445;});}})[_0x998f('0x23')](respondWithFilteredResult(_0x21a2e8,_0x91d6f8))[_0x998f('0x29')](handleError(_0x21a2e8,null));};exports['removeDispositions']=function(_0x34d7ae,_0x27fd04,_0x1f66bb){return db['OpenchannelAccount']['find']({'where':{'id':_0x34d7ae['params']['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x27fd04,null))[_0x998f('0x23')](function(_0x2f3d6c){if(_0x2f3d6c){return _0x2f3d6c[_0x998f('0x6b')](_0x34d7ae[_0x998f('0x43')][_0x998f('0x6c')]);}})[_0x998f('0x23')](respondWithStatusCode(_0x27fd04,null))[_0x998f('0x29')](handleError(_0x27fd04,null));};exports[_0x998f('0x6d')]=function(_0x25ff5f,_0xf2c72b,_0x1d070b){if(_0x25ff5f['body']['id']){delete _0x25ff5f[_0x998f('0x59')]['id'];}return db['OpenchannelAccount'][_0x998f('0x63')]({'where':{'id':_0x25ff5f['params']['id']}})['then'](handleEntityNotFound(_0xf2c72b,null))[_0x998f('0x23')](function(_0x4f0ab5){if(_0x4f0ab5){_0x25ff5f[_0x998f('0x59')][_0x998f('0x69')]=_0x4f0ab5['id'];return db[_0x998f('0x6e')][_0x998f('0x58')](_0x25ff5f[_0x998f('0x59')]);}})[_0x998f('0x23')](respondWithResult(_0xf2c72b,null))['catch'](handleError(_0xf2c72b,null));};exports[_0x998f('0x6f')]=function(_0x5d6d85,_0x78db71,_0x5cdf18){var _0x3995a9={'raw':![],'where':{}};var _0x2c6ff8={};var _0x1e719e={'count':0x0,'rows':[]};return db[_0x998f('0x3f')][_0x998f('0x66')]({'where':{'id':_0x5d6d85['params']['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x78db71,null))[_0x998f('0x23')](function(_0x515d5d){if(_0x515d5d){_0x2c6ff8['model']=_['keys'](db['CannedAnswer'][_0x998f('0x67')]);_0x2c6ff8['query']=_[_0x998f('0x55')](_0x5d6d85[_0x998f('0x43')]);_0x2c6ff8['filters']=_['intersection'](_0x2c6ff8[_0x998f('0x42')],_0x2c6ff8[_0x998f('0x43')]);_0x3995a9[_0x998f('0x45')]=_['intersection'](_0x2c6ff8[_0x998f('0x42')],qs[_0x998f('0x46')](_0x5d6d85[_0x998f('0x43')][_0x998f('0x46')]));_0x3995a9['attributes']=_0x3995a9['attributes'][_0x998f('0x57')]?_0x3995a9[_0x998f('0x45')]:_0x2c6ff8[_0x998f('0x42')];if(!_0x5d6d85[_0x998f('0x43')]['hasOwnProperty']('nolimit')){_0x3995a9[_0x998f('0x2e')]=qs[_0x998f('0x2e')](_0x5d6d85[_0x998f('0x43')]['limit']);_0x3995a9[_0x998f('0x2d')]=qs['offset'](_0x5d6d85[_0x998f('0x43')][_0x998f('0x2d')]);}_0x3995a9[_0x998f('0x49')]=qs[_0x998f('0x68')](_0x5d6d85['query']['sort']);_0x3995a9[_0x998f('0x4a')]=qs['filters'](_[_0x998f('0x4b')](_0x5d6d85['query'],_0x2c6ff8['filters']));_0x3995a9[_0x998f('0x4a')][_0x998f('0x69')]=_0x515d5d['id'];if(_0x5d6d85['query'][_0x998f('0x4c')]){_0x3995a9[_0x998f('0x4a')]=_[_0x998f('0x4e')](_0x3995a9[_0x998f('0x4a')],{'$or':_[_0x998f('0x3e')](_0x3995a9[_0x998f('0x45')],function(_0x533a95){var _0x53cb19={};_0x53cb19[_0x533a95]={'$like':'%'+_0x5d6d85[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x53cb19;})});}_0x3995a9=_[_0x998f('0x4e')]({},_0x3995a9,_0x5d6d85[_0x998f('0x4f')]);return db['CannedAnswer'][_0x998f('0x2c')]({'where':_0x3995a9[_0x998f('0x4a')]})[_0x998f('0x23')](function(_0x21eb4b){_0x1e719e[_0x998f('0x2c')]=_0x21eb4b;if(_0x5d6d85[_0x998f('0x43')][_0x998f('0x50')]){_0x3995a9[_0x998f('0x51')]=[{'all':!![]}];}return db['CannedAnswer']['findAll'](_0x3995a9);})[_0x998f('0x23')](function(_0x2da523){_0x1e719e['rows']=_0x2da523;return _0x1e719e;});}})[_0x998f('0x23')](respondWithFilteredResult(_0x78db71,_0x3995a9))[_0x998f('0x29')](handleError(_0x78db71,null));};exports[_0x998f('0x70')]=function(_0x2979ae,_0x200b32,_0x893fde){return db[_0x998f('0x3f')][_0x998f('0x63')]({'where':{'id':_0x2979ae[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x200b32,null))[_0x998f('0x23')](function(_0x229448){if(_0x229448){return _0x229448[_0x998f('0x70')](_0x2979ae[_0x998f('0x43')][_0x998f('0x6c')]);}})[_0x998f('0x23')](respondWithStatusCode(_0x200b32,null))[_0x998f('0x29')](handleError(_0x200b32,null));};exports[_0x998f('0x71')]=function(_0x10fa96,_0x4ddf4b,_0x1b2e04){var _0x2f0e5f={'body':_0x10fa96['body'],'channel':_0x998f('0x72')};var _0x2023ca=[];var _0x185aa3=[];var _0x760dd2={};var _0x311051=![];return db['CmContact'][_0x998f('0x62')]()[_0x998f('0x23')](function(_0x1a53a1){if(!_0x1a53a1){throw new db[(_0x998f('0x73'))][(_0x998f('0x74'))](_0x998f('0x75'));}_0x2023ca=_[_0x998f('0x76')](_[_0x998f('0x55')](_0x1a53a1),[_0x998f('0x77'),_0x998f('0x78')]);_0x185aa3=_[_0x998f('0x76')](_[_0x998f('0x55')](_0x1a53a1),[_0x998f('0x77'),_0x998f('0x78'),_0x998f('0x79'),'ListId']);if(_0x10fa96[_0x998f('0x59')]['id']){delete _0x10fa96[_0x998f('0x59')]['id'];}if(_[_0x998f('0x7a')](_0x10fa96['body'][_0x998f('0x7b')])){throw new db[(_0x998f('0x73'))]['ValidationError'](_0x998f('0x7c'));}if(_['isNil'](_0x10fa96[_0x998f('0x59')][_0x998f('0x59')])||_0x10fa96['body'][_0x998f('0x59')]===''){throw new db[(_0x998f('0x73'))][(_0x998f('0x74'))](_0x998f('0x7d'));}if(_[_0x998f('0x7a')](_0x10fa96[_0x998f('0x59')]['mapKey'])){throw new db[(_0x998f('0x73'))][(_0x998f('0x74'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x185aa3);}if(!_[_0x998f('0x7e')](_0x185aa3,_0x10fa96[_0x998f('0x59')][_0x998f('0x7f')])){throw new db[(_0x998f('0x73'))][(_0x998f('0x74'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x185aa3);}_0x760dd2[_0x10fa96[_0x998f('0x59')][_0x998f('0x7f')]]=_0x10fa96[_0x998f('0x59')]['from'];})[_0x998f('0x23')](function(){return db[_0x998f('0x3f')]['find']({'where':{'id':_0x10fa96[_0x998f('0x54')]['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db[_0x998f('0x80')],'as':_0x998f('0x81'),'where':_0x760dd2,'limit':0x1,'order':[['updatedAt',_0x998f('0x82')]]}]},{'model':db['OpenchannelApplication'],'as':_0x998f('0x83')}]});})['then'](handleEntityNotFound(_0x4ddf4b,null))[_0x998f('0x23')](function(_0x23e8bf){if(_0x23e8bf&&_0x23e8bf[_0x998f('0x84')]){_0x2f0e5f[_0x998f('0x85')]=_0x23e8bf;_0x2f0e5f[_0x998f('0x86')]=_0x23e8bf[_0x998f('0x83')];_0x2f0e5f[_0x998f('0x87')]=_0x23e8bf[_0x998f('0x84')];_0x2f0e5f[_0x998f('0x86')]=_[_0x998f('0x88')](_0x2f0e5f[_0x998f('0x86')],['priority'],['asc']);if(_0x2f0e5f[_0x998f('0x85')][_0x998f('0x83')]){delete _0x2f0e5f['account'][_0x998f('0x83')];}if(_0x2f0e5f[_0x998f('0x85')][_0x998f('0x84')]&&_0x2f0e5f[_0x998f('0x85')][_0x998f('0x84')][_0x998f('0x81')][_0x998f('0x57')]){return _0x2f0e5f['account'][_0x998f('0x84')]['Contacts'][0x0];}var _0x418494=_['defaults'](_0x10fa96[_0x998f('0x59')],{'firstName':_0x10fa96[_0x998f('0x59')][_0x998f('0x7b')],'ListId':_0x23e8bf[_0x998f('0x89')]});_0x418494[_0x10fa96['body'][_0x998f('0x7f')]]=_0x10fa96['body'][_0x998f('0x7b')];return db[_0x998f('0x80')][_0x998f('0x58')](_0x418494,{'fields':_0x2023ca,'raw':!![]});}})[_0x998f('0x23')](handleEntityNotFound(_0x4ddf4b,null))[_0x998f('0x23')](function(_0x730ee2){_0x2f0e5f[_0x998f('0x8a')]=_0x730ee2;if(_0x730ee2){var _0x3147f8={'ContactId':_0x730ee2['id'],'OpenchannelAccountId':_0x10fa96[_0x998f('0x54')]['id'],'from':(_0x730ee2[_0x998f('0x8b')]||'')+'\x20'+(_0x730ee2[_0x998f('0x8c')]||'')};var _0x23ea47={'OpenchannelAccountId':_0x10fa96[_0x998f('0x54')]['id'],'closed':![]};if(_0x10fa96[_0x998f('0x59')]['threadId']){_0x23ea47['threadId']=_0x10fa96[_0x998f('0x59')][_0x998f('0x8d')];return db[_0x998f('0x8e')][_0x998f('0x63')]({'where':_0x23ea47})[_0x998f('0x23')](function(_0x1ad479){if(_0x1ad479){return[_0x1ad479,![]];}_0x3147f8[_0x998f('0x8d')]=_0x10fa96['body']['threadId'];_0x3147f8[_0x998f('0x8f')]=_0x10fa96[_0x998f('0x59')][_0x998f('0x8f')];return db[_0x998f('0x8e')][_0x998f('0x58')](_0x3147f8)[_0x998f('0x23')](function(_0x511031){return[_0x511031,!![]];});});}else{_0x23ea47[_0x998f('0x8d')]=null;}_0x23ea47[_0x998f('0x90')]=_0x730ee2['id'];return db[_0x998f('0x8e')]['find']({'where':_0x23ea47})['then'](function(_0x1ebf31){if(_0x1ebf31){return[_0x1ebf31,![]];}return db['OpenchannelInteraction'][_0x998f('0x58')](_0x3147f8)[_0x998f('0x23')](function(_0x5f92d6){return[_0x5f92d6,!![]];});});}})[_0x998f('0x91')](function(_0x3267b5,_0x43b3f0){if(_0x3267b5){_0x311051=_0x43b3f0;if(!_0x43b3f0){var _0x2dfd1f={'from':(_0x2f0e5f[_0x998f('0x8a')]['firstName']||'')+'\x20'+(_0x2f0e5f[_0x998f('0x8a')]['lastName']||'')};if(_0x10fa96[_0x998f('0x59')][_0x998f('0x8d')]&&_0x10fa96[_0x998f('0x59')][_0x998f('0x92')]&&_0x10fa96[_0x998f('0x59')]['threadId']!=_0x10fa96[_0x998f('0x59')][_0x998f('0x92')]){_0x2dfd1f['threadId']=_0x10fa96[_0x998f('0x59')][_0x998f('0x92')];}return _0x3267b5['update'](_0x2dfd1f);}else{return _0x3267b5;}}})[_0x998f('0x23')](function(_0xee789c){_0x2f0e5f[_0x998f('0x93')]=_0xee789c[_0x998f('0x5b')]({'plain':!![]});_0x2f0e5f[_0x998f('0x93')][_0x998f('0x94')]=_0x311051;if(_0x2f0e5f['interaction'][_0x998f('0x94')]){if(_0x2f0e5f[_0x998f('0x85')][_0x998f('0x95')]){_0x2f0e5f['applications'][_0x998f('0x96')]({'id':0x0,'priority':_0x2f0e5f[_0x998f('0x86')]['length']+0x1,'app':'close','appdata':_0x998f('0x97'),'interval':'*,*,*,*'});}}return db[_0x998f('0x98')][_0x998f('0x58')]({'body':_0x10fa96[_0x998f('0x59')][_0x998f('0x59')],'OpenchannelAccountId':_0x10fa96[_0x998f('0x54')]['id'],'OpenchannelInteractionId':_0xee789c['id'],'direction':'in','ContactId':_0x2f0e5f[_0x998f('0x8a')]['id'],'AttachmentId':_0x10fa96['body'][_0x998f('0x99')]});})[_0x998f('0x23')](function(_0x139da8){_0x2f0e5f[_0x998f('0x28')]=_0x139da8;if(_0x2f0e5f['interaction'][_0x998f('0x9a')]){return db[_0x998f('0x9b')][_0x998f('0x63')]({'attributes':['id','name'],'where':{'id':_0x2f0e5f[_0x998f('0x93')]['UserId']}})[_0x998f('0x23')](function(_0x53ef82){if(_0x53ef82){_0x2f0e5f[_0x998f('0x86')][_0x998f('0x9c')]({'id':0x0,'priority':0x0,'app':_0x998f('0x9d'),'appdata':_0x53ef82[_0x998f('0x3a')]+','+(_0x2f0e5f[_0x998f('0x85')][_0x998f('0x9e')]||0xa),'interval':_0x998f('0x9f')});_0x2f0e5f[_0x998f('0xa0')]=![];}return respondWithRpcPromise(_0x998f('0xa1'),_0x998f('0xa2'),_0x2f0e5f);});}return respondWithRpcPromise(_0x998f('0xa1'),_0x998f('0xa2'),_0x2f0e5f);})[_0x998f('0x23')](function(_0x22b0e9){respondWithRpcPromise('EventManager',_0x998f('0xa3'),{'event':'notify','message':_0x22b0e9},client9002);return _0x22b0e9;})[_0x998f('0x23')](respondWithResult(_0x4ddf4b,null))['catch'](handleError(_0x4ddf4b,null));};exports[_0x998f('0xa4')]=function(_0x357246,_0x5016f7,_0x67475b){return db[_0x998f('0x3f')][_0x998f('0x66')]({'where':{'id':_0x357246['params']['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x5016f7,null))['then'](function(_0x5abff1){if(_0x5abff1){return db[_0x998f('0xa5')][_0x998f('0xa6')](function(_0xc39d2d){return db[_0x998f('0xa7')][_0x998f('0x35')]({'where':{'OpenchannelAccountId':_0x357246[_0x998f('0x54')]['id']},'transaction':_0xc39d2d})[_0x998f('0x23')](function(_0x431578){var _0x55c899=_[_0x998f('0x3e')](_0x357246[_0x998f('0x59')],function(_0x5859c2){_0x5859c2[_0x998f('0x69')]=_0x357246[_0x998f('0x54')]['id'];return _0x5859c2;});return db[_0x998f('0xa7')][_0x998f('0xa8')](_0x55c899,{'transaction':_0xc39d2d});});})[_0x998f('0x23')](function(){return db[_0x998f('0xa7')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0x357246[_0x998f('0x54')]['id']},'order':_0x998f('0xa9')});});}})[_0x998f('0x23')](respondWithResult(_0x5016f7,null))[_0x998f('0x29')](handleError(_0x5016f7,null));};exports[_0x998f('0xaa')]=function(_0xcea3e9,_0x5e9615,_0x116378){var _0x3ba660={};var _0x2e9c66={};var _0x484805;var _0x1f9d6f;return db[_0x998f('0x3f')][_0x998f('0x66')]({'where':{'id':_0xcea3e9['params']['id']}})['then'](handleEntityNotFound(_0x5e9615,null))[_0x998f('0x23')](function(_0x4434d4){if(_0x4434d4){_0x484805=_0x4434d4;_0x2e9c66['model']=_[_0x998f('0x55')](db['OpenchannelApplication'][_0x998f('0x67')]);_0x2e9c66[_0x998f('0x43')]=_['keys'](_0xcea3e9[_0x998f('0x43')]);_0x2e9c66[_0x998f('0x44')]=_[_0x998f('0x56')](_0x2e9c66['model'],_0x2e9c66[_0x998f('0x43')]);_0x3ba660[_0x998f('0x45')]=_[_0x998f('0x56')](_0x2e9c66[_0x998f('0x42')],qs[_0x998f('0x46')](_0xcea3e9[_0x998f('0x43')]['fields']));_0x3ba660[_0x998f('0x45')]=_0x3ba660[_0x998f('0x45')][_0x998f('0x57')]?_0x3ba660[_0x998f('0x45')]:_0x2e9c66[_0x998f('0x42')];_0x3ba660[_0x998f('0x49')]=qs[_0x998f('0x68')](_0xcea3e9[_0x998f('0x43')]['sort']);_0x3ba660[_0x998f('0x4a')]=qs['filters'](_[_0x998f('0x4b')](_0xcea3e9[_0x998f('0x43')],_0x2e9c66['filters']));if(_0xcea3e9['query'][_0x998f('0x4c')]){_0x3ba660[_0x998f('0x4a')]=_[_0x998f('0x4e')](_0x3ba660[_0x998f('0x4a')],{'$or':_[_0x998f('0x3e')](_0x3ba660[_0x998f('0x45')],function(_0x194fa8){var _0x34e410={};_0x34e410[_0x194fa8]={'$like':'%'+_0xcea3e9[_0x998f('0x43')]['filter']+'%'};return _0x34e410;})});}_0x3ba660=_[_0x998f('0x4e')]({},_0x3ba660,_0xcea3e9['options']);return _0x484805[_0x998f('0xaa')](_0x3ba660);}})[_0x998f('0x23')](function(_0x427f77){if(_0x427f77){_0x1f9d6f=_0x427f77['length'];if(!_0xcea3e9[_0x998f('0x43')][_0x998f('0x47')](_0x998f('0x48'))){_0x3ba660[_0x998f('0x2e')]=qs['limit'](_0xcea3e9['query'][_0x998f('0x2e')]);_0x3ba660[_0x998f('0x2d')]=qs[_0x998f('0x2d')](_0xcea3e9[_0x998f('0x43')][_0x998f('0x2d')]);}return _0x484805['getApplications'](_0x3ba660);}})[_0x998f('0x23')](function(_0x339f8c){if(_0x339f8c){return _0x339f8c?{'count':_0x1f9d6f,'rows':_0x339f8c}:null;}})[_0x998f('0x23')](respondWithResult(_0x5e9615,null))['catch'](handleError(_0x5e9615,null));};exports['getInteractions']=function(_0x4ee278,_0x1259be,_0x7c5798){var _0x25cd1a={'raw':![],'where':{}};var _0x470df5={};var _0x4791e8={'count':0x0,'rows':[]};return db['OpenchannelAccount']['findOne']({'where':{'id':_0x4ee278[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x1259be,null))[_0x998f('0x23')](function(_0x110ccf){if(_0x110ccf){_0x470df5['model']=_[_0x998f('0x55')](db['OpenchannelInteraction'][_0x998f('0x67')]);_0x470df5[_0x998f('0x43')]=_[_0x998f('0x55')](_0x4ee278[_0x998f('0x43')]);_0x470df5[_0x998f('0x44')]=_[_0x998f('0x56')](_0x470df5['model'],_0x470df5[_0x998f('0x43')]);_0x25cd1a['attributes']=_[_0x998f('0x56')](_0x470df5['model'],qs[_0x998f('0x46')](_0x4ee278[_0x998f('0x43')][_0x998f('0x46')]));_0x25cd1a['attributes']=_0x25cd1a[_0x998f('0x45')][_0x998f('0x57')]?_0x25cd1a[_0x998f('0x45')]:_0x470df5['model'];if(!_0x4ee278['query']['hasOwnProperty'](_0x998f('0x48'))){_0x25cd1a[_0x998f('0x2e')]=qs[_0x998f('0x2e')](_0x4ee278[_0x998f('0x43')]['limit']);_0x25cd1a[_0x998f('0x2d')]=qs['offset'](_0x4ee278['query']['offset']);}_0x25cd1a[_0x998f('0x49')]=qs[_0x998f('0x68')](_0x4ee278[_0x998f('0x43')][_0x998f('0x68')]);_0x25cd1a[_0x998f('0x4a')]=qs[_0x998f('0x44')](_[_0x998f('0x4b')](_0x4ee278[_0x998f('0x43')],_0x470df5[_0x998f('0x44')]));_0x25cd1a[_0x998f('0x4a')]['OpenchannelAccountId']=_0x110ccf['id'];if(_0x4ee278[_0x998f('0x43')][_0x998f('0x4c')]){_0x25cd1a[_0x998f('0x4a')]=_[_0x998f('0x4e')](_0x25cd1a['where'],{'$or':_[_0x998f('0x3e')](_0x25cd1a[_0x998f('0x45')],function(_0x51d3d0){var _0x16bff3={};_0x16bff3[_0x51d3d0]={'$like':'%'+_0x4ee278[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x16bff3;})});}_0x25cd1a=_[_0x998f('0x4e')]({},_0x25cd1a,_0x4ee278['options']);return db[_0x998f('0x8e')][_0x998f('0x2c')]({'where':_0x25cd1a[_0x998f('0x4a')]})[_0x998f('0x23')](function(_0x358778){_0x4791e8[_0x998f('0x2c')]=_0x358778;if(_0x4ee278[_0x998f('0x43')][_0x998f('0x50')]){_0x25cd1a[_0x998f('0x51')]=[{'model':db[_0x998f('0x80')],'as':_0x998f('0xab'),'required':![]},{'model':db[_0x998f('0x9b')],'as':_0x998f('0xac'),'attributes':[_0x998f('0x3a'),_0x998f('0xad'),'internal'],'required':![]},{'model':db[_0x998f('0xae')],'as':_0x998f('0xaf'),'attributes':['id',_0x998f('0x3a'),'color'],'where':_0x4ee278[_0x998f('0x43')]['tag']?{'id':_0x4ee278['query']['tag']}:undefined,'required':_0x4ee278[_0x998f('0x43')]['tag']?!![]:![]}];}return db[_0x998f('0x8e')][_0x998f('0x52')](_0x25cd1a);})[_0x998f('0x23')](function(_0x1de9c5){_0x4791e8[_0x998f('0x6a')]=_0x1de9c5;return _0x4791e8;});}})[_0x998f('0x23')](respondWithFilteredResult(_0x1259be,_0x25cd1a))[_0x998f('0x29')](handleError(_0x1259be,null));};exports[_0x998f('0xb0')]=function(_0x527e07,_0x5d5da2,_0x21470d){return db[_0x998f('0x3f')][_0x998f('0x63')]({'where':{'id':_0x527e07[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x5d5da2,null))[_0x998f('0x23')](function(_0x51ee3d){if(_0x51ee3d){return _0x51ee3d['addAgents'](_0x527e07[_0x998f('0x59')][_0x998f('0x6c')],_[_0x998f('0xb1')](_0x527e07[_0x998f('0x59')],[_0x998f('0x6c'),'id'])||{})[_0x998f('0x91')](function(_0x58549a){for(var _0x4f705d=0x0;_0x4f705d<_0x527e07[_0x998f('0x59')][_0x998f('0x6c')]['length'];_0x4f705d+=0x1){socket[_0x998f('0xb2')]('userOpenchannelAccount:save',{'UserId':_0x527e07[_0x998f('0x59')][_0x998f('0x6c')][_0x4f705d],'OpenchannelAccountId':_0x527e07[_0x998f('0x54')]['id']});}return _0x58549a;});}})[_0x998f('0x23')](respondWithResult(_0x5d5da2,null))[_0x998f('0x29')](handleError(_0x5d5da2,null));};exports['removeAgents']=function(_0xaf5b31,_0x150384,_0x33fb99){return db[_0x998f('0x3f')][_0x998f('0x63')]({'where':{'id':_0xaf5b31[_0x998f('0x54')]['id']}})['then'](handleEntityNotFound(_0x150384,null))[_0x998f('0x23')](function(_0x269792){if(_0x269792){return _0x269792[_0x998f('0xb3')](_0xaf5b31['query'][_0x998f('0x6c')])[_0x998f('0x23')](function(){if(_[_0x998f('0xb4')](_0xaf5b31[_0x998f('0x43')][_0x998f('0x6c')])){for(var _0x50fa73=0x0;_0x50fa73<_0xaf5b31[_0x998f('0x43')]['ids'][_0x998f('0x57')];_0x50fa73+=0x1){socket[_0x998f('0xb2')]('userOpenchannelAccount:remove',{'UserId':Number(_0xaf5b31[_0x998f('0x43')][_0x998f('0x6c')][_0x50fa73]),'OpenchannelAccountId':Number(_0xaf5b31['params']['id'])});}}else{socket[_0x998f('0xb2')](_0x998f('0xb5'),{'UserId':Number(_0xaf5b31[_0x998f('0x43')]['ids']),'OpenchannelAccountId':Number(_0xaf5b31[_0x998f('0x54')]['id'])});}});}})['then'](respondWithStatusCode(_0x150384,null))[_0x998f('0x29')](handleError(_0x150384,null));};exports[_0x998f('0xb6')]=function(_0x2e8626,_0xfbe6c9,_0x24c2ba){var _0x4a2340={};var _0x12d850={};var _0x831c54;var _0xf7cc33;return db['OpenchannelAccount'][_0x998f('0x66')]({'where':{'id':_0x2e8626['params']['id']}})['then'](handleEntityNotFound(_0xfbe6c9,null))['then'](function(_0x2967f0){if(_0x2967f0){_0x831c54=_0x2967f0;_0x12d850['model']=_[_0x998f('0x55')](db[_0x998f('0x9b')][_0x998f('0x67')]);_0x12d850[_0x998f('0x43')]=_['keys'](_0x2e8626[_0x998f('0x43')]);_0x12d850[_0x998f('0x44')]=_[_0x998f('0x56')](_0x12d850[_0x998f('0x42')],_0x12d850[_0x998f('0x43')]);_0x4a2340['attributes']=_[_0x998f('0x56')](_0x12d850[_0x998f('0x42')],qs['fields'](_0x2e8626[_0x998f('0x43')]['fields']));_0x4a2340[_0x998f('0x45')]=_0x4a2340[_0x998f('0x45')]['length']?_0x4a2340[_0x998f('0x45')]:_0x12d850['model'];_0x4a2340[_0x998f('0x49')]=qs[_0x998f('0x68')](_0x2e8626['query'][_0x998f('0x68')]);_0x4a2340[_0x998f('0x4a')]=qs[_0x998f('0x44')](_[_0x998f('0x4b')](_0x2e8626['query'],_0x12d850['filters']));if(_0x2e8626[_0x998f('0x43')][_0x998f('0x4c')]){_0x4a2340[_0x998f('0x4a')]=_['merge'](_0x4a2340[_0x998f('0x4a')],{'$or':_[_0x998f('0x3e')](_0x4a2340['attributes'],function(_0x15e2d5){var _0x3ddc7b={};_0x3ddc7b[_0x15e2d5]={'$like':'%'+_0x2e8626[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x3ddc7b;})});}_0x4a2340=_['merge']({},_0x4a2340,_0x2e8626[_0x998f('0x4f')]);return _0x831c54['getAgents'](_0x4a2340);}})[_0x998f('0x23')](function(_0x4c1ab0){if(_0x4c1ab0){_0xf7cc33=_0x4c1ab0[_0x998f('0x57')];if(!_0x2e8626[_0x998f('0x43')]['hasOwnProperty'](_0x998f('0x48'))){_0x4a2340[_0x998f('0x2e')]=qs[_0x998f('0x2e')](_0x2e8626[_0x998f('0x43')][_0x998f('0x2e')]);_0x4a2340[_0x998f('0x2d')]=qs[_0x998f('0x2d')](_0x2e8626[_0x998f('0x43')][_0x998f('0x2d')]);}return _0x831c54[_0x998f('0xb6')](_0x4a2340);}})[_0x998f('0x23')](function(_0x4cbfbb){if(_0x4cbfbb){return _0x4cbfbb?{'count':_0xf7cc33,'rows':_0x4cbfbb}:null;}})[_0x998f('0x23')](respondWithResult(_0xfbe6c9,null))[_0x998f('0x29')](handleError(_0xfbe6c9,null));};exports[_0x998f('0xb7')]=function(_0x450082,_0x2ce5d4,_0x3c505f){var _0x303062,_0x58ed8a,_0x44c74e;if(_[_0x998f('0x7a')](_0x450082[_0x998f('0x59')][_0x998f('0x59')])||_0x450082['body'][_0x998f('0x59')]===''){throw new db['Sequelize'][(_0x998f('0x74'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x450082[_0x998f('0x59')]['to'])){}_0x303062=_0x450082[_0x998f('0x59')]['to'];return db[_0x998f('0x3f')]['findOne']({'where':{'id':_0x450082[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x2ce5d4,null))[_0x998f('0x23')](function(_0x399df6){if(_0x399df6){return db['OpenchannelAccount']['find']({'where':{'id':_0x399df6['id']},'include':[{'model':db[_0x998f('0xb8')],'as':_0x998f('0x84'),'include':[{'model':db[_0x998f('0x80')],'as':_0x998f('0x81'),'where':{[_0x399df6['mapKey']]:_0x303062},'limit':0x1,'order':[[_0x998f('0x78'),_0x998f('0x82')]]}]}]})['then'](handleEntityNotFound(_0x2ce5d4,null))[_0x998f('0x23')](function(_0x46e156){if(_0x46e156&&_0x46e156[_0x998f('0x84')]){_0x58ed8a=_0x46e156['get']({'plain':!![]});if(_0x58ed8a['List']&&_0x58ed8a['List'][_0x998f('0x81')][_0x998f('0x57')]){return _0x58ed8a[_0x998f('0x84')]['Contacts'][0x0];}return db['CmContact'][_0x998f('0x58')](_[_0x998f('0x19')](_0x450082['body'],{'firstName':_0x303062,[_0x46e156['mapKey']]:_0x303062,'phone':_0x303062,'ListId':_0x58ed8a[_0x998f('0x89')]}));}})['then'](handleEntityNotFound(_0x2ce5d4,null))[_0x998f('0x23')](function(_0x5e3e48){if(_0x5e3e48){_0x44c74e=_0x5e3e48;return db[_0x998f('0x8e')]['find']({'where':{'ContactId':_0x44c74e['id'],'closed':![],'OpenchannelAccountId':_0x58ed8a['id']}})['then'](function(_0x305ea0){if(_0x305ea0){return[_0x305ea0,![]];}return db[_0x998f('0x8e')][_0x998f('0x58')]({'UserId':_0x450082['user']['id'],'ContactId':_0x44c74e['id'],'OpenchannelAccountId':_0x58ed8a['id'],'lastMsgDirection':'out','Messages':[_['merge'](_0x450082[_0x998f('0x59')],{'read':![],'body':_0x450082[_0x998f('0x59')][_0x998f('0x59')],'OpenchannelAccountId':_0x58ed8a['id'],'UserId':_0x450082[_0x998f('0x5a')]['id'],'ContactId':_0x44c74e['id']})]},{'include':[{'model':db[_0x998f('0x98')],'as':_0x998f('0xb9')}]})[_0x998f('0x23')](function(_0x39c96b){return[_0x39c96b,!![]];});});}})[_0x998f('0x91')](function(_0x2cca3f,_0x552a23){if(_0x552a23){return _0x2cca3f;}return db[_0x998f('0x98')][_0x998f('0x58')](_[_0x998f('0x4e')](_0x450082['body'],{'read':![],'body':_0x450082['body'][_0x998f('0x59')],'OpenchannelAccountId':_0x58ed8a['id'],'OpenchannelInteractionId':_0x2cca3f['id'],'UserId':_0x450082[_0x998f('0x5a')]['id'],'ContactId':_0x44c74e['id']}))[_0x998f('0x23')](function(_0x5da56e){_0x2cca3f[_0x998f('0xba')][_0x998f('0xb9')]=[];_0x2cca3f[_0x998f('0xba')][_0x998f('0xb9')][_0x998f('0x96')](_0x5da56e[_0x998f('0xba')]);return _0x2cca3f;});});}})['then'](respondWithResult(_0x2ce5d4,null))[_0x998f('0x29')](handleError(_0x2ce5d4,null));};
\ No newline at end of file