Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index 7b894b9..a9fb154 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8f05=['Tags','color','tag','addAgents','emit','userOpenchannelAccount:save','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','CmList','DESC','out','dataValues','Messages','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','register','jayson/promise','client','http','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info','result','catch','sendStatus','status','end','json','undefined','offset','count','set','Content-Range','apply','reject','save','update','then','destroy','get','OpenchannelAccounts','UserProfileResource','name','send','index','Pause','mandatoryDispositionPause','rawAttributes','type','model','map','query','keys','intersection','attributes','fields','nolimit','limit','order','sort','where','filters','filter','merge','options','OpenchannelAccount','include','findAll','rows','show','params','includeAll','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','autoAssociation','body','describe','OpenchannelAccountId','getDispositions','length','hasOwnProperty','Disposition','removeDispositions','ids','addAnswer','CannedAnswer','findOne','pick','removeAnswers','openchannel','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','isNil','from','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','Contacts','OpenchannelApplication','Applications','account','applications','list','orderBy','ListId','contact','lastName','threadId','OpenchannelInteraction','externalUrl','spread','firstName','messageId','interaction','created','autoclose','close','unmanaged','*,*,*,*','OpenchannelMessage','AttachmentId','UserId','unshift','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','notify','addApplications','sequelize','Transaction','READ_COMMITTED','priority','finally','getInteractions','Contact','User','fullname','internal'];(function(_0xfb7ee3,_0x6f1f19){var _0x5c061d=function(_0x404867){while(--_0x404867){_0xfb7ee3['push'](_0xfb7ee3['shift']());}};_0x5c061d(++_0x6f1f19);}(_0x8f05,0x17f));var _0x58f0=function(_0x3498e5,_0x1f78fd){_0x3498e5=_0x3498e5-0x0;var _0x3fe3fd=_0x8f05[_0x3498e5];return _0x3fe3fd;};'use strict';var emlformat=require(_0x58f0('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x58f0('0x1'));var jsonpatch=require(_0x58f0('0x2'));var rp=require(_0x58f0('0x3'));var moment=require(_0x58f0('0x4'));var BPromise=require(_0x58f0('0x5'));var Mustache=require('mustache');var util=require(_0x58f0('0x6'));var path=require(_0x58f0('0x7'));var sox=require(_0x58f0('0x8'));var csv=require(_0x58f0('0x9'));var ejs=require(_0x58f0('0xa'));var fs=require('fs');var fs_extra=require(_0x58f0('0xb'));var _=require(_0x58f0('0xc'));var squel=require('squel');var crypto=require(_0x58f0('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x58f0('0x9'));var querystring=require(_0x58f0('0xe'));var Papa=require(_0x58f0('0xf'));var Redis=require(_0x58f0('0x10'));var authService=require(_0x58f0('0x11'));var qs=require(_0x58f0('0x12'));var as=require(_0x58f0('0x13'));var hardwareService=require(_0x58f0('0x14'));var logger=require(_0x58f0('0x15'))(_0x58f0('0x16'));var utils=require(_0x58f0('0x17'));var config=require(_0x58f0('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x58f0('0x19'))['db'];config['redis']=_[_0x58f0('0x1a')](config[_0x58f0('0x1b')],{'host':_0x58f0('0x1c'),'port':0x18eb});var socket=require(_0x58f0('0x1d'))(new Redis(config[_0x58f0('0x1b')]));require('./openchannelAccount.socket')[_0x58f0('0x1e')](socket);var jayson=require(_0x58f0('0x1f'));var client=jayson[_0x58f0('0x20')][_0x58f0('0x21')]({'port':0x232c});var client9002=jayson[_0x58f0('0x20')][_0x58f0('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x12e0e4,_0x489422,_0x443eee,_0x53dc8a){return new BPromise(function(_0x4c6156,_0x199ad3){var _0x8a19e0=_0x53dc8a||client;return _0x8a19e0['request'](_0x12e0e4,_0x443eee)['then'](function(_0x3f9df9){logger['info'](_0x58f0('0x22'),_0x489422,_0x58f0('0x23'));logger[_0x58f0('0x24')]('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0x489422,'request\x20sent',JSON[_0x58f0('0x25')](_0x3f9df9));if(_0x3f9df9[_0x58f0('0x26')]){if(_0x3f9df9['error']['code']===0x1f4){logger[_0x58f0('0x26')](_0x58f0('0x22'),_0x489422,_0x3f9df9[_0x58f0('0x26')][_0x58f0('0x27')]);return _0x199ad3(_0x3f9df9[_0x58f0('0x26')]['message']);}logger[_0x58f0('0x26')]('OpenchannelAccount,\x20%s,\x20%s',_0x489422,_0x3f9df9['error'][_0x58f0('0x27')]);return _0x4c6156(_0x3f9df9[_0x58f0('0x26')][_0x58f0('0x27')]);}else{logger[_0x58f0('0x28')](_0x58f0('0x22'),_0x489422,_0x58f0('0x23'));_0x4c6156(_0x3f9df9[_0x58f0('0x29')][_0x58f0('0x27')]);}})[_0x58f0('0x2a')](function(_0x2bf9cd){logger['error'](_0x58f0('0x22'),_0x489422,_0x2bf9cd);_0x199ad3(_0x2bf9cd);});});}function respondWithStatusCode(_0x50b83e,_0x3ceb4a){_0x3ceb4a=_0x3ceb4a||0xcc;return function(_0x17cff0){if(_0x17cff0){return _0x50b83e[_0x58f0('0x2b')](_0x3ceb4a);}return _0x50b83e[_0x58f0('0x2c')](_0x3ceb4a)[_0x58f0('0x2d')]();};}function respondWithResult(_0x4268e0,_0x4d36c7){_0x4d36c7=_0x4d36c7||0xc8;return function(_0x39efbc){if(_0x39efbc){return _0x4268e0[_0x58f0('0x2c')](_0x4d36c7)[_0x58f0('0x2e')](_0x39efbc);}};}function respondWithFilteredResult(_0x1daaee,_0x2b97fa){return function(_0x4cda3c){if(_0x4cda3c){var _0x5dbfe6=typeof _0x2b97fa['offset']===_0x58f0('0x2f')&&typeof _0x2b97fa['limit']===_0x58f0('0x2f');var _0x429eb8=_0x4cda3c['count'];var _0xf3a9c8=_0x5dbfe6?0x0:_0x2b97fa[_0x58f0('0x30')];var _0x39f473=_0x5dbfe6?_0x4cda3c[_0x58f0('0x31')]:_0x2b97fa[_0x58f0('0x30')]+_0x2b97fa['limit'];var _0x58ea59;if(_0x39f473>=_0x429eb8){_0x39f473=_0x429eb8;_0x58ea59=0xc8;}else{_0x58ea59=0xce;}_0x1daaee[_0x58f0('0x2c')](_0x58ea59);return _0x1daaee[_0x58f0('0x32')](_0x58f0('0x33'),_0xf3a9c8+'-'+_0x39f473+'/'+_0x429eb8)[_0x58f0('0x2e')](_0x4cda3c);}return null;};}function patchUpdates(_0x74562){return function(_0x5da849){try{jsonpatch[_0x58f0('0x34')](_0x5da849,_0x74562,!![]);}catch(_0x10ddde){return BPromise[_0x58f0('0x35')](_0x10ddde);}return _0x5da849[_0x58f0('0x36')]();};}function saveUpdates(_0x2b97de,_0x306f90){return function(_0x471713){if(_0x471713){return _0x471713[_0x58f0('0x37')](_0x2b97de)[_0x58f0('0x38')](function(_0x244f23){return _0x244f23;});}return null;};}function removeEntity(_0x74a521,_0x4f460e){return function(_0x3758a7){if(_0x3758a7){return _0x3758a7[_0x58f0('0x39')]()[_0x58f0('0x38')](function(){var _0x190976=_0x3758a7[_0x58f0('0x3a')]({'plain':!![]});var _0x419392=_0x58f0('0x3b');return db[_0x58f0('0x3c')][_0x58f0('0x39')]({'where':{'type':_0x419392,'resourceId':_0x190976['id']}})['then'](function(){return _0x3758a7;});})[_0x58f0('0x38')](function(){_0x74a521[_0x58f0('0x2c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4a8ccc,_0x449c8c){return function(_0x13ad17){if(!_0x13ad17){_0x4a8ccc[_0x58f0('0x2b')](0x194);}return _0x13ad17;};}function handleError(_0x40be99,_0x48fcb2){_0x48fcb2=_0x48fcb2||0x1f4;return function(_0x50461b){logger[_0x58f0('0x26')](_0x50461b['stack']);if(_0x50461b[_0x58f0('0x3d')]){delete _0x50461b[_0x58f0('0x3d')];}_0x40be99[_0x58f0('0x2c')](_0x48fcb2)[_0x58f0('0x3e')](_0x50461b);};}exports[_0x58f0('0x3f')]=function(_0x5cc2bb,_0x347209){var _0x22aab2={'include':[{'model':db[_0x58f0('0x40')],'as':_0x58f0('0x41')}]},_0x63c233={},_0x3a50e0={'count':0x0,'rows':[]};var _0x5b3fc9=_['map'](db['OpenchannelAccount'][_0x58f0('0x42')],function(_0x4a7c79){return{'name':_0x4a7c79['fieldName'],'type':_0x4a7c79[_0x58f0('0x43')]['key']};});_0x63c233[_0x58f0('0x44')]=_[_0x58f0('0x45')](_0x5b3fc9,'name');_0x63c233[_0x58f0('0x46')]=_[_0x58f0('0x47')](_0x5cc2bb[_0x58f0('0x46')]);_0x63c233['filters']=_[_0x58f0('0x48')](_0x63c233[_0x58f0('0x44')],_0x63c233[_0x58f0('0x46')]);_0x22aab2[_0x58f0('0x49')]=_[_0x58f0('0x48')](_0x63c233[_0x58f0('0x44')],qs[_0x58f0('0x4a')](_0x5cc2bb[_0x58f0('0x46')]['fields']));_0x22aab2[_0x58f0('0x49')]=_0x22aab2[_0x58f0('0x49')]['length']?_0x22aab2[_0x58f0('0x49')]:_0x63c233[_0x58f0('0x44')];if(!_0x5cc2bb[_0x58f0('0x46')]['hasOwnProperty'](_0x58f0('0x4b'))){_0x22aab2[_0x58f0('0x4c')]=qs[_0x58f0('0x4c')](_0x5cc2bb[_0x58f0('0x46')][_0x58f0('0x4c')]);_0x22aab2[_0x58f0('0x30')]=qs[_0x58f0('0x30')](_0x5cc2bb[_0x58f0('0x46')]['offset']);}_0x22aab2[_0x58f0('0x4d')]=qs[_0x58f0('0x4e')](_0x5cc2bb[_0x58f0('0x46')][_0x58f0('0x4e')]);_0x22aab2[_0x58f0('0x4f')]=qs[_0x58f0('0x50')](_['pick'](_0x5cc2bb['query'],_0x63c233[_0x58f0('0x50')]),_0x5b3fc9);if(_0x5cc2bb[_0x58f0('0x46')][_0x58f0('0x51')]){_0x22aab2[_0x58f0('0x4f')]=_[_0x58f0('0x52')](_0x22aab2[_0x58f0('0x4f')],{'$or':_[_0x58f0('0x45')](_0x5b3fc9,function(_0x18c063){if(_0x18c063[_0x58f0('0x43')]!=='VIRTUAL'){var _0x4acba2={};_0x4acba2[_0x18c063[_0x58f0('0x3d')]]={'$like':'%'+_0x5cc2bb['query'][_0x58f0('0x51')]+'%'};return _0x4acba2;}})});}_0x22aab2=_['merge']({},_0x22aab2,_0x5cc2bb[_0x58f0('0x53')]);var _0x17de75={'where':_0x22aab2[_0x58f0('0x4f')]};return db[_0x58f0('0x54')][_0x58f0('0x31')](_0x17de75)['then'](function(_0x229d8e){_0x3a50e0['count']=_0x229d8e;if(_0x5cc2bb[_0x58f0('0x46')]['includeAll']){_0x22aab2[_0x58f0('0x55')]=[{'all':!![]}];}return db[_0x58f0('0x54')][_0x58f0('0x56')](_0x22aab2);})[_0x58f0('0x38')](function(_0x539f18){_0x3a50e0[_0x58f0('0x57')]=_0x539f18;return _0x3a50e0;})[_0x58f0('0x38')](respondWithFilteredResult(_0x347209,_0x22aab2))[_0x58f0('0x2a')](handleError(_0x347209,null));};exports[_0x58f0('0x58')]=function(_0x361507,_0x57b2b1){var _0x18eca3={'raw':![],'where':{'id':_0x361507[_0x58f0('0x59')]['id']},'include':[{'model':db[_0x58f0('0x40')],'as':_0x58f0('0x41')}]},_0x1dbdbf={};_0x1dbdbf['model']=_[_0x58f0('0x47')](db[_0x58f0('0x54')][_0x58f0('0x42')]);_0x1dbdbf[_0x58f0('0x46')]=_[_0x58f0('0x47')](_0x361507[_0x58f0('0x46')]);_0x1dbdbf[_0x58f0('0x50')]=_[_0x58f0('0x48')](_0x1dbdbf[_0x58f0('0x44')],_0x1dbdbf[_0x58f0('0x46')]);_0x18eca3[_0x58f0('0x49')]=_['intersection'](_0x1dbdbf[_0x58f0('0x44')],qs['fields'](_0x361507['query'][_0x58f0('0x4a')]));_0x18eca3[_0x58f0('0x49')]=_0x18eca3[_0x58f0('0x49')]['length']?_0x18eca3[_0x58f0('0x49')]:_0x1dbdbf[_0x58f0('0x44')];if(_0x361507[_0x58f0('0x46')][_0x58f0('0x5a')]){_0x18eca3['include']=[{'all':!![]}];}_0x18eca3=_[_0x58f0('0x52')]({},_0x18eca3,_0x361507[_0x58f0('0x53')]);return db[_0x58f0('0x54')][_0x58f0('0x5b')](_0x18eca3)['then'](handleEntityNotFound(_0x57b2b1,null))['then'](respondWithResult(_0x57b2b1,null))[_0x58f0('0x2a')](handleError(_0x57b2b1,null));};exports['create']=function(_0x1e2082,_0x3e02ad){return db[_0x58f0('0x54')][_0x58f0('0x5c')](_0x1e2082['body'],{})[_0x58f0('0x38')](function(_0x272f38){var _0x2dbf6d=_0x1e2082[_0x58f0('0x5d')][_0x58f0('0x3a')]({'plain':!![]});if(!_0x2dbf6d)throw new Error(_0x58f0('0x5e'));if(_0x2dbf6d[_0x58f0('0x5f')]===_0x58f0('0x5d')){var _0x30e8dc=_0x272f38[_0x58f0('0x3a')]({'plain':!![]});var _0x6381f3=_0x58f0('0x3b');return db['UserProfileSection'][_0x58f0('0x5b')]({'where':{'name':_0x6381f3,'userProfileId':_0x2dbf6d['userProfileId']},'raw':!![]})['then'](function(_0x5c6a6b){if(_0x5c6a6b&&_0x5c6a6b[_0x58f0('0x60')]===0x0){return db[_0x58f0('0x3c')]['create']({'name':_0x30e8dc[_0x58f0('0x3d')],'resourceId':_0x30e8dc['id'],'type':_0x5c6a6b[_0x58f0('0x3d')],'sectionId':_0x5c6a6b['id']},{})[_0x58f0('0x38')](function(){return _0x272f38;});}else{return _0x272f38;}})[_0x58f0('0x2a')](function(_0x4b5e56){logger[_0x58f0('0x26')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4b5e56);throw _0x4b5e56;});}return _0x272f38;})[_0x58f0('0x38')](respondWithResult(_0x3e02ad,0xc9))[_0x58f0('0x2a')](handleError(_0x3e02ad,null));};exports[_0x58f0('0x37')]=function(_0x35a148,_0x114329){if(_0x35a148[_0x58f0('0x61')]['id']){delete _0x35a148[_0x58f0('0x61')]['id'];}return db[_0x58f0('0x54')][_0x58f0('0x5b')]({'where':{'id':_0x35a148[_0x58f0('0x59')]['id']},'include':[{'model':db[_0x58f0('0x40')],'as':_0x58f0('0x41')}]})['then'](handleEntityNotFound(_0x114329,null))[_0x58f0('0x38')](saveUpdates(_0x35a148[_0x58f0('0x61')],null))[_0x58f0('0x38')](respondWithResult(_0x114329,null))['catch'](handleError(_0x114329,null));};exports[_0x58f0('0x39')]=function(_0x360aeb,_0x8af34c){return db[_0x58f0('0x54')][_0x58f0('0x5b')]({'where':{'id':_0x360aeb[_0x58f0('0x59')]['id']}})['then'](handleEntityNotFound(_0x8af34c,null))[_0x58f0('0x38')](removeEntity(_0x8af34c,null))[_0x58f0('0x2a')](handleError(_0x8af34c,null));};exports[_0x58f0('0x62')]=function(_0x154e33,_0x49daa1){return db[_0x58f0('0x54')][_0x58f0('0x62')]()[_0x58f0('0x38')](respondWithResult(_0x49daa1,null))[_0x58f0('0x2a')](handleError(_0x49daa1,null));};exports['addDisposition']=function(_0x47b142,_0x20cbdb,_0x163b13){if(_0x47b142[_0x58f0('0x61')]['id']){delete _0x47b142['body']['id'];}return db['OpenchannelAccount'][_0x58f0('0x5b')]({'where':{'id':_0x47b142['params']['id']}})['then'](handleEntityNotFound(_0x20cbdb,null))['then'](function(_0xee0d0a){if(_0xee0d0a){_0x47b142[_0x58f0('0x61')][_0x58f0('0x63')]=_0xee0d0a['id'];return db['Disposition'][_0x58f0('0x5c')](_0x47b142[_0x58f0('0x61')]);}})['then'](respondWithResult(_0x20cbdb,null))['catch'](handleError(_0x20cbdb,null));};exports[_0x58f0('0x64')]=function(_0x1fd60c,_0x5e4212,_0x13399e){var _0x58f606={'raw':![],'where':{}};var _0x5a7e84={};var _0x2da62a={'count':0x0,'rows':[]};return db[_0x58f0('0x54')]['findOne']({'where':{'id':_0x1fd60c['params']['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x5e4212,null))[_0x58f0('0x38')](function(_0x44339f){if(_0x44339f){_0x5a7e84[_0x58f0('0x44')]=_[_0x58f0('0x47')](db['Disposition']['rawAttributes']);_0x5a7e84['query']=_[_0x58f0('0x47')](_0x1fd60c[_0x58f0('0x46')]);_0x5a7e84[_0x58f0('0x50')]=_[_0x58f0('0x48')](_0x5a7e84[_0x58f0('0x44')],_0x5a7e84[_0x58f0('0x46')]);_0x58f606['attributes']=_[_0x58f0('0x48')](_0x5a7e84['model'],qs['fields'](_0x1fd60c[_0x58f0('0x46')][_0x58f0('0x4a')]));_0x58f606[_0x58f0('0x49')]=_0x58f606['attributes'][_0x58f0('0x65')]?_0x58f606['attributes']:_0x5a7e84['model'];if(!_0x1fd60c[_0x58f0('0x46')][_0x58f0('0x66')](_0x58f0('0x4b'))){_0x58f606[_0x58f0('0x4c')]=qs[_0x58f0('0x4c')](_0x1fd60c[_0x58f0('0x46')][_0x58f0('0x4c')]);_0x58f606[_0x58f0('0x30')]=qs['offset'](_0x1fd60c[_0x58f0('0x46')][_0x58f0('0x30')]);}_0x58f606['order']=qs[_0x58f0('0x4e')](_0x1fd60c[_0x58f0('0x46')]['sort']);_0x58f606[_0x58f0('0x4f')]=qs[_0x58f0('0x50')](_['pick'](_0x1fd60c[_0x58f0('0x46')],_0x5a7e84[_0x58f0('0x50')]));_0x58f606['where']['OpenchannelAccountId']=_0x44339f['id'];if(_0x1fd60c[_0x58f0('0x46')][_0x58f0('0x51')]){_0x58f606[_0x58f0('0x4f')]=_[_0x58f0('0x52')](_0x58f606[_0x58f0('0x4f')],{'$or':_[_0x58f0('0x45')](_0x58f606[_0x58f0('0x49')],function(_0x219fe6){var _0x1d6f2e={};_0x1d6f2e[_0x219fe6]={'$like':'%'+_0x1fd60c[_0x58f0('0x46')][_0x58f0('0x51')]+'%'};return _0x1d6f2e;})});}_0x58f606=_[_0x58f0('0x52')]({},_0x58f606,_0x1fd60c[_0x58f0('0x53')]);return db[_0x58f0('0x67')]['count']({'where':_0x58f606[_0x58f0('0x4f')]})[_0x58f0('0x38')](function(_0x5162f8){_0x2da62a[_0x58f0('0x31')]=_0x5162f8;if(_0x1fd60c[_0x58f0('0x46')][_0x58f0('0x5a')]){_0x58f606[_0x58f0('0x55')]=[{'all':!![]}];}return db[_0x58f0('0x67')][_0x58f0('0x56')](_0x58f606);})[_0x58f0('0x38')](function(_0x23a3cb){_0x2da62a[_0x58f0('0x57')]=_0x23a3cb;return _0x2da62a;});}})['then'](respondWithFilteredResult(_0x5e4212,_0x58f606))[_0x58f0('0x2a')](handleError(_0x5e4212,null));};exports[_0x58f0('0x68')]=function(_0x3febeb,_0x15c963,_0x50d54f){return db[_0x58f0('0x54')]['find']({'where':{'id':_0x3febeb[_0x58f0('0x59')]['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x15c963,null))[_0x58f0('0x38')](function(_0x1b81f3){if(_0x1b81f3){return _0x1b81f3['removeDispositions'](_0x3febeb['query'][_0x58f0('0x69')]);}})[_0x58f0('0x38')](respondWithStatusCode(_0x15c963,null))[_0x58f0('0x2a')](handleError(_0x15c963,null));};exports[_0x58f0('0x6a')]=function(_0x3cd443,_0xbb1b9a,_0x5a4952){if(_0x3cd443[_0x58f0('0x61')]['id']){delete _0x3cd443[_0x58f0('0x61')]['id'];}return db[_0x58f0('0x54')]['find']({'where':{'id':_0x3cd443[_0x58f0('0x59')]['id']}})['then'](handleEntityNotFound(_0xbb1b9a,null))[_0x58f0('0x38')](function(_0x6d67cf){if(_0x6d67cf){_0x3cd443[_0x58f0('0x61')][_0x58f0('0x63')]=_0x6d67cf['id'];return db[_0x58f0('0x6b')][_0x58f0('0x5c')](_0x3cd443['body']);}})[_0x58f0('0x38')](respondWithResult(_0xbb1b9a,null))[_0x58f0('0x2a')](handleError(_0xbb1b9a,null));};exports['getAnswers']=function(_0x2b5833,_0x10b301,_0x3f7b03){var _0x56980b={'raw':![],'where':{}};var _0x3cb448={};var _0x1057f0={'count':0x0,'rows':[]};return db['OpenchannelAccount'][_0x58f0('0x6c')]({'where':{'id':_0x2b5833[_0x58f0('0x59')]['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x10b301,null))['then'](function(_0xca4ca8){if(_0xca4ca8){_0x3cb448[_0x58f0('0x44')]=_[_0x58f0('0x47')](db[_0x58f0('0x6b')][_0x58f0('0x42')]);_0x3cb448[_0x58f0('0x46')]=_[_0x58f0('0x47')](_0x2b5833[_0x58f0('0x46')]);_0x3cb448[_0x58f0('0x50')]=_['intersection'](_0x3cb448['model'],_0x3cb448[_0x58f0('0x46')]);_0x56980b[_0x58f0('0x49')]=_[_0x58f0('0x48')](_0x3cb448[_0x58f0('0x44')],qs[_0x58f0('0x4a')](_0x2b5833[_0x58f0('0x46')]['fields']));_0x56980b[_0x58f0('0x49')]=_0x56980b[_0x58f0('0x49')][_0x58f0('0x65')]?_0x56980b[_0x58f0('0x49')]:_0x3cb448[_0x58f0('0x44')];if(!_0x2b5833[_0x58f0('0x46')][_0x58f0('0x66')]('nolimit')){_0x56980b[_0x58f0('0x4c')]=qs[_0x58f0('0x4c')](_0x2b5833[_0x58f0('0x46')][_0x58f0('0x4c')]);_0x56980b[_0x58f0('0x30')]=qs[_0x58f0('0x30')](_0x2b5833[_0x58f0('0x46')][_0x58f0('0x30')]);}_0x56980b[_0x58f0('0x4d')]=qs[_0x58f0('0x4e')](_0x2b5833[_0x58f0('0x46')][_0x58f0('0x4e')]);_0x56980b[_0x58f0('0x4f')]=qs[_0x58f0('0x50')](_[_0x58f0('0x6d')](_0x2b5833[_0x58f0('0x46')],_0x3cb448['filters']));_0x56980b[_0x58f0('0x4f')][_0x58f0('0x63')]=_0xca4ca8['id'];if(_0x2b5833[_0x58f0('0x46')][_0x58f0('0x51')]){_0x56980b[_0x58f0('0x4f')]=_[_0x58f0('0x52')](_0x56980b[_0x58f0('0x4f')],{'$or':_[_0x58f0('0x45')](_0x56980b[_0x58f0('0x49')],function(_0x576c73){var _0x19f538={};_0x19f538[_0x576c73]={'$like':'%'+_0x2b5833[_0x58f0('0x46')]['filter']+'%'};return _0x19f538;})});}_0x56980b=_[_0x58f0('0x52')]({},_0x56980b,_0x2b5833[_0x58f0('0x53')]);return db[_0x58f0('0x6b')][_0x58f0('0x31')]({'where':_0x56980b[_0x58f0('0x4f')]})[_0x58f0('0x38')](function(_0x4dd35f){_0x1057f0['count']=_0x4dd35f;if(_0x2b5833[_0x58f0('0x46')][_0x58f0('0x5a')]){_0x56980b[_0x58f0('0x55')]=[{'all':!![]}];}return db[_0x58f0('0x6b')]['findAll'](_0x56980b);})[_0x58f0('0x38')](function(_0x53c34c){_0x1057f0['rows']=_0x53c34c;return _0x1057f0;});}})['then'](respondWithFilteredResult(_0x10b301,_0x56980b))['catch'](handleError(_0x10b301,null));};exports[_0x58f0('0x6e')]=function(_0x1ba9fd,_0x40e186,_0x1a963b){return db[_0x58f0('0x54')][_0x58f0('0x5b')]({'where':{'id':_0x1ba9fd['params']['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x40e186,null))['then'](function(_0x45eb6b){if(_0x45eb6b){return _0x45eb6b['removeAnswers'](_0x1ba9fd[_0x58f0('0x46')][_0x58f0('0x69')]);}})['then'](respondWithStatusCode(_0x40e186,null))[_0x58f0('0x2a')](handleError(_0x40e186,null));};exports['notify']=function(_0x5c9e6a,_0x4fb206,_0x3edcff){var _0x5f0af5={'body':_0x5c9e6a[_0x58f0('0x61')],'channel':_0x58f0('0x6f')};var _0x4b0de9=[];var _0x351787=[];var _0x70b4ab={};var _0x30c024=![];return db[_0x58f0('0x70')]['describe']()[_0x58f0('0x38')](function(_0x3992f0){if(!_0x3992f0){throw new db[(_0x58f0('0x71'))][(_0x58f0('0x72'))](_0x58f0('0x73'));}_0x4b0de9=_[_0x58f0('0x74')](_[_0x58f0('0x47')](_0x3992f0),[_0x58f0('0x75'),'updatedAt']);_0x351787=_['difference'](_[_0x58f0('0x47')](_0x3992f0),[_0x58f0('0x75'),_0x58f0('0x76'),'CompanyId','ListId']);if(_0x5c9e6a[_0x58f0('0x61')]['id']){delete _0x5c9e6a[_0x58f0('0x61')]['id'];}if(_[_0x58f0('0x77')](_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x78')])){throw new db['Sequelize'][(_0x58f0('0x72'))]('from\x20is\x20mandatory');}if(_[_0x58f0('0x77')](_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x61')])||_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x61')]===''){throw new db[(_0x58f0('0x71'))][(_0x58f0('0x72'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x58f0('0x77')](_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x79')])){throw new db[(_0x58f0('0x71'))]['ValidationError'](_0x58f0('0x7a')+_0x351787);}if(!_[_0x58f0('0x7b')](_0x351787,_0x5c9e6a['body'][_0x58f0('0x79')])){throw new db[(_0x58f0('0x71'))][(_0x58f0('0x72'))](_0x58f0('0x7c')+_0x351787);}_0x70b4ab[_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x79')]]=_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x78')];})[_0x58f0('0x38')](function(){return db['OpenchannelAccount'][_0x58f0('0x5b')]({'where':{'id':_0x5c9e6a[_0x58f0('0x59')]['id']},'include':[{'model':db['CmList'],'as':_0x58f0('0x7d'),'include':[{'model':db[_0x58f0('0x70')],'as':_0x58f0('0x7e'),'where':_0x70b4ab,'limit':0x1,'order':[[_0x58f0('0x76'),'DESC']]}]},{'model':db[_0x58f0('0x7f')],'as':_0x58f0('0x80')}]});})[_0x58f0('0x38')](handleEntityNotFound(_0x4fb206,null))['then'](function(_0x46bbf1){if(_0x46bbf1&&_0x46bbf1[_0x58f0('0x7d')]){_0x5f0af5[_0x58f0('0x81')]=_0x46bbf1;_0x5f0af5[_0x58f0('0x82')]=_0x46bbf1['Applications'];_0x5f0af5[_0x58f0('0x83')]=_0x46bbf1['List'];_0x5f0af5['applications']=_[_0x58f0('0x84')](_0x5f0af5[_0x58f0('0x82')],['priority'],['asc']);if(_0x5f0af5[_0x58f0('0x81')][_0x58f0('0x80')]){delete _0x5f0af5[_0x58f0('0x81')][_0x58f0('0x80')];}if(_0x5f0af5[_0x58f0('0x81')]['List']&&_0x5f0af5[_0x58f0('0x81')][_0x58f0('0x7d')][_0x58f0('0x7e')][_0x58f0('0x65')]){return _0x5f0af5[_0x58f0('0x81')][_0x58f0('0x7d')]['Contacts'][0x0];}var _0x19d5ba=_[_0x58f0('0x1a')](_0x5c9e6a[_0x58f0('0x61')],{'firstName':_0x5c9e6a[_0x58f0('0x61')]['from'],'ListId':_0x46bbf1[_0x58f0('0x85')]});_0x19d5ba[_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x79')]]=_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x78')];return db[_0x58f0('0x70')][_0x58f0('0x5c')](_0x19d5ba,{'fields':_0x4b0de9,'raw':!![]});}})[_0x58f0('0x38')](handleEntityNotFound(_0x4fb206,null))[_0x58f0('0x38')](function(_0x2cac81){_0x5f0af5[_0x58f0('0x86')]=_0x2cac81;if(_0x2cac81){var _0x4de82b={'ContactId':_0x2cac81['id'],'OpenchannelAccountId':_0x5c9e6a[_0x58f0('0x59')]['id'],'from':(_0x2cac81['firstName']||'')+'\x20'+(_0x2cac81[_0x58f0('0x87')]||'')};var _0x5ae696={'OpenchannelAccountId':_0x5c9e6a[_0x58f0('0x59')]['id'],'closed':![]};if(_0x5c9e6a['body'][_0x58f0('0x88')]){_0x5ae696[_0x58f0('0x88')]=_0x5c9e6a[_0x58f0('0x61')]['threadId'];return db[_0x58f0('0x89')][_0x58f0('0x5b')]({'where':_0x5ae696})['then'](function(_0xb8b7b7){if(_0xb8b7b7){return[_0xb8b7b7,![]];}_0x4de82b[_0x58f0('0x88')]=_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x88')];_0x4de82b[_0x58f0('0x8a')]=_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x8a')];return db[_0x58f0('0x89')][_0x58f0('0x5c')](_0x4de82b)['then'](function(_0x16ad6a){return[_0x16ad6a,!![]];});});}else{_0x5ae696[_0x58f0('0x88')]=null;}_0x5ae696['ContactId']=_0x2cac81['id'];return db[_0x58f0('0x89')][_0x58f0('0x5b')]({'where':_0x5ae696})[_0x58f0('0x38')](function(_0x40a707){if(_0x40a707){return[_0x40a707,![]];}return db['OpenchannelInteraction']['create'](_0x4de82b)[_0x58f0('0x38')](function(_0x5869d2){return[_0x5869d2,!![]];});});}})[_0x58f0('0x8b')](function(_0x2fc394,_0x2c602d){if(_0x2fc394){_0x30c024=_0x2c602d;if(!_0x2c602d){var _0x3a2d08={'from':(_0x5f0af5[_0x58f0('0x86')][_0x58f0('0x8c')]||'')+'\x20'+(_0x5f0af5[_0x58f0('0x86')][_0x58f0('0x87')]||'')};if(_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x88')]&&_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x8d')]&&_0x5c9e6a['body'][_0x58f0('0x88')]!=_0x5c9e6a[_0x58f0('0x61')]['messageId']){_0x3a2d08[_0x58f0('0x88')]=_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x8d')];}return _0x2fc394['update'](_0x3a2d08);}else{return _0x2fc394;}}})[_0x58f0('0x38')](function(_0x1177d7){_0x5f0af5[_0x58f0('0x8e')]=_0x1177d7[_0x58f0('0x3a')]({'plain':!![]});_0x5f0af5['interaction'][_0x58f0('0x8f')]=_0x30c024;if(_0x5f0af5[_0x58f0('0x8e')][_0x58f0('0x8f')]){if(_0x5f0af5['account'][_0x58f0('0x90')]){_0x5f0af5['applications']['push']({'id':0x0,'priority':_0x5f0af5[_0x58f0('0x82')][_0x58f0('0x65')]+0x1,'app':_0x58f0('0x91'),'appdata':_0x58f0('0x92'),'interval':_0x58f0('0x93')});}}return db[_0x58f0('0x94')][_0x58f0('0x5c')]({'body':_0x5c9e6a['body'][_0x58f0('0x61')],'OpenchannelAccountId':_0x5c9e6a[_0x58f0('0x59')]['id'],'OpenchannelInteractionId':_0x1177d7['id'],'direction':'in','ContactId':_0x5f0af5[_0x58f0('0x86')]['id'],'AttachmentId':_0x5c9e6a[_0x58f0('0x61')][_0x58f0('0x95')]});})[_0x58f0('0x38')](function(_0x3ded16){_0x5f0af5[_0x58f0('0x27')]=_0x3ded16;if(_0x5f0af5[_0x58f0('0x8e')]['UserId']){return db['User'][_0x58f0('0x5b')]({'attributes':['id',_0x58f0('0x3d')],'where':{'id':_0x5f0af5['interaction'][_0x58f0('0x96')]}})[_0x58f0('0x38')](function(_0x1adf3b){if(_0x1adf3b){_0x5f0af5['applications'][_0x58f0('0x97')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x1adf3b[_0x58f0('0x3d')]+','+(_0x5f0af5[_0x58f0('0x81')][_0x58f0('0x98')]||0xa),'interval':_0x58f0('0x93')});_0x5f0af5[_0x58f0('0x99')]=![];}return respondWithRpcPromise(_0x58f0('0x9a'),_0x58f0('0x9b'),_0x5f0af5);});}return respondWithRpcPromise(_0x58f0('0x9a'),_0x58f0('0x9b'),_0x5f0af5);})[_0x58f0('0x38')](function(_0x5102c1){respondWithRpcPromise(_0x58f0('0x9c'),_0x58f0('0x9c'),{'event':_0x58f0('0x9d'),'message':_0x5102c1},client9002);return _0x5102c1;})[_0x58f0('0x38')](respondWithResult(_0x4fb206,null))[_0x58f0('0x2a')](handleError(_0x4fb206,null));};exports[_0x58f0('0x9e')]=function(_0x466a5c,_0x2abe6f){var _0x329c33=_0x466a5c[_0x58f0('0x59')]['id'];var _0x262631=_0x466a5c[_0x58f0('0x61')];var _0x1c080b=0xc8;var _0x551f65=null;return db[_0x58f0('0x9f')]['transaction']({'isolationLevel':db['sequelize'][_0x58f0('0xa0')]['ISOLATION_LEVELS'][_0x58f0('0xa1')]},function(_0x367901){return db[_0x58f0('0x54')][_0x58f0('0x6c')]({'where':{'id':_0x329c33},'transaction':_0x367901})[_0x58f0('0x38')](function(_0x392e6b){if(_0x392e6b){return db[_0x58f0('0x7f')]['destroy']({'where':{'OpenchannelAccountId':_0x329c33},'transaction':_0x367901})[_0x58f0('0x38')](function(){var _0xc85dd5=_['map'](_0x262631,function(_0x1e68ab){_0x1e68ab[_0x58f0('0x63')]=_0x329c33;return _0x1e68ab;});return db[_0x58f0('0x7f')]['bulkCreate'](_0xc85dd5,{'transaction':_0x367901});});}else{_0x1c080b=0x194;_0x551f65=[];}});})[_0x58f0('0x38')](function(){if(_0x1c080b!==0x194){return db[_0x58f0('0x7f')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0x329c33},'order':_0x58f0('0xa2')})['then'](function(_0x5d2e84){_0x551f65=_0x5d2e84;});}})[_0x58f0('0x2a')](function(_0x4f06dd){_0x1c080b=0x1f4;logger['error'](_0x4f06dd['stack']);if(_0x4f06dd[_0x58f0('0x3d')]){delete _0x4f06dd[_0x58f0('0x3d')];}_0x551f65=_0x4f06dd;})[_0x58f0('0xa3')](function(){if(_0x551f65===null){_0x2abe6f[_0x58f0('0x2b')](_0x1c080b);}else{if(_0x1c080b===0x1f4){_0x2abe6f[_0x58f0('0x2c')](_0x1c080b)[_0x58f0('0x3e')](_0x551f65);}else{_0x2abe6f[_0x58f0('0x2c')](_0x1c080b)['json'](_0x551f65);}}});};exports['getApplications']=function(_0x13180a,_0x30c12b,_0x30d644){var _0x3ccf7a={};var _0x18a63e={};var _0x379fb9;var _0x5882ed;return db[_0x58f0('0x54')]['findOne']({'where':{'id':_0x13180a['params']['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x30c12b,null))['then'](function(_0x5e370a){if(_0x5e370a){_0x379fb9=_0x5e370a;_0x18a63e[_0x58f0('0x44')]=_['keys'](db[_0x58f0('0x7f')][_0x58f0('0x42')]);_0x18a63e[_0x58f0('0x46')]=_[_0x58f0('0x47')](_0x13180a['query']);_0x18a63e['filters']=_[_0x58f0('0x48')](_0x18a63e[_0x58f0('0x44')],_0x18a63e[_0x58f0('0x46')]);_0x3ccf7a['attributes']=_[_0x58f0('0x48')](_0x18a63e['model'],qs[_0x58f0('0x4a')](_0x13180a[_0x58f0('0x46')][_0x58f0('0x4a')]));_0x3ccf7a['attributes']=_0x3ccf7a[_0x58f0('0x49')][_0x58f0('0x65')]?_0x3ccf7a[_0x58f0('0x49')]:_0x18a63e[_0x58f0('0x44')];_0x3ccf7a[_0x58f0('0x4d')]=qs[_0x58f0('0x4e')](_0x13180a[_0x58f0('0x46')][_0x58f0('0x4e')]);_0x3ccf7a[_0x58f0('0x4f')]=qs['filters'](_[_0x58f0('0x6d')](_0x13180a['query'],_0x18a63e[_0x58f0('0x50')]));if(_0x13180a[_0x58f0('0x46')]['filter']){_0x3ccf7a[_0x58f0('0x4f')]=_[_0x58f0('0x52')](_0x3ccf7a[_0x58f0('0x4f')],{'$or':_[_0x58f0('0x45')](_0x3ccf7a[_0x58f0('0x49')],function(_0x14a5fc){var _0x3a1e5d={};_0x3a1e5d[_0x14a5fc]={'$like':'%'+_0x13180a[_0x58f0('0x46')][_0x58f0('0x51')]+'%'};return _0x3a1e5d;})});}_0x3ccf7a=_[_0x58f0('0x52')]({},_0x3ccf7a,_0x13180a[_0x58f0('0x53')]);return _0x379fb9['getApplications'](_0x3ccf7a);}})[_0x58f0('0x38')](function(_0x6fd16e){if(_0x6fd16e){_0x5882ed=_0x6fd16e[_0x58f0('0x65')];if(!_0x13180a['query']['hasOwnProperty'](_0x58f0('0x4b'))){_0x3ccf7a[_0x58f0('0x4c')]=qs[_0x58f0('0x4c')](_0x13180a[_0x58f0('0x46')][_0x58f0('0x4c')]);_0x3ccf7a[_0x58f0('0x30')]=qs[_0x58f0('0x30')](_0x13180a[_0x58f0('0x46')][_0x58f0('0x30')]);}return _0x379fb9['getApplications'](_0x3ccf7a);}})[_0x58f0('0x38')](function(_0x53b0ed){if(_0x53b0ed){return _0x53b0ed?{'count':_0x5882ed,'rows':_0x53b0ed}:null;}})[_0x58f0('0x38')](respondWithResult(_0x30c12b,null))[_0x58f0('0x2a')](handleError(_0x30c12b,null));};exports[_0x58f0('0xa4')]=function(_0x1931f5,_0x1028fc,_0x5ad008){var _0x203052={'raw':![],'where':{}};var _0x3d91b5={};var _0x37a801={'count':0x0,'rows':[]};return db[_0x58f0('0x54')][_0x58f0('0x6c')]({'where':{'id':_0x1931f5[_0x58f0('0x59')]['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x1028fc,null))[_0x58f0('0x38')](function(_0x3df0bf){if(_0x3df0bf){_0x3d91b5[_0x58f0('0x44')]=_['keys'](db[_0x58f0('0x89')][_0x58f0('0x42')]);_0x3d91b5[_0x58f0('0x46')]=_[_0x58f0('0x47')](_0x1931f5[_0x58f0('0x46')]);_0x3d91b5['filters']=_['intersection'](_0x3d91b5[_0x58f0('0x44')],_0x3d91b5[_0x58f0('0x46')]);_0x203052['attributes']=_[_0x58f0('0x48')](_0x3d91b5[_0x58f0('0x44')],qs[_0x58f0('0x4a')](_0x1931f5[_0x58f0('0x46')][_0x58f0('0x4a')]));_0x203052[_0x58f0('0x49')]=_0x203052[_0x58f0('0x49')][_0x58f0('0x65')]?_0x203052[_0x58f0('0x49')]:_0x3d91b5[_0x58f0('0x44')];if(!_0x1931f5['query'][_0x58f0('0x66')](_0x58f0('0x4b'))){_0x203052['limit']=qs[_0x58f0('0x4c')](_0x1931f5[_0x58f0('0x46')][_0x58f0('0x4c')]);_0x203052[_0x58f0('0x30')]=qs[_0x58f0('0x30')](_0x1931f5[_0x58f0('0x46')][_0x58f0('0x30')]);}_0x203052[_0x58f0('0x4d')]=qs[_0x58f0('0x4e')](_0x1931f5[_0x58f0('0x46')]['sort']);_0x203052['where']=qs['filters'](_[_0x58f0('0x6d')](_0x1931f5[_0x58f0('0x46')],_0x3d91b5[_0x58f0('0x50')]));_0x203052[_0x58f0('0x4f')][_0x58f0('0x63')]=_0x3df0bf['id'];if(_0x1931f5[_0x58f0('0x46')][_0x58f0('0x51')]){_0x203052[_0x58f0('0x4f')]=_['merge'](_0x203052[_0x58f0('0x4f')],{'$or':_[_0x58f0('0x45')](_0x203052[_0x58f0('0x49')],function(_0x203d6d){var _0xda5328={};_0xda5328[_0x203d6d]={'$like':'%'+_0x1931f5['query'][_0x58f0('0x51')]+'%'};return _0xda5328;})});}_0x203052=_[_0x58f0('0x52')]({},_0x203052,_0x1931f5[_0x58f0('0x53')]);return db[_0x58f0('0x89')][_0x58f0('0x31')]({'where':_0x203052[_0x58f0('0x4f')]})[_0x58f0('0x38')](function(_0x6c96cc){_0x37a801['count']=_0x6c96cc;if(_0x1931f5[_0x58f0('0x46')]['includeAll']){_0x203052[_0x58f0('0x55')]=[{'model':db[_0x58f0('0x70')],'as':_0x58f0('0xa5'),'required':![]},{'model':db[_0x58f0('0xa6')],'as':'Owner','attributes':[_0x58f0('0x3d'),_0x58f0('0xa7'),_0x58f0('0xa8')],'required':![]},{'model':db['Tag'],'as':_0x58f0('0xa9'),'attributes':['id',_0x58f0('0x3d'),_0x58f0('0xaa')],'where':_0x1931f5[_0x58f0('0x46')][_0x58f0('0xab')]?{'id':_0x1931f5[_0x58f0('0x46')]['tag']}:undefined,'required':_0x1931f5[_0x58f0('0x46')][_0x58f0('0xab')]?!![]:![]}];}return db[_0x58f0('0x89')][_0x58f0('0x56')](_0x203052);})['then'](function(_0x3653b1){_0x37a801[_0x58f0('0x57')]=_0x3653b1;return _0x37a801;});}})[_0x58f0('0x38')](respondWithFilteredResult(_0x1028fc,_0x203052))[_0x58f0('0x2a')](handleError(_0x1028fc,null));};exports[_0x58f0('0xac')]=function(_0x91c507,_0x2cdd80,_0xad6b3d){return db[_0x58f0('0x54')][_0x58f0('0x5b')]({'where':{'id':_0x91c507['params']['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x2cdd80,null))['then'](function(_0x1dc19f){if(_0x1dc19f){return _0x1dc19f['addAgents'](_0x91c507[_0x58f0('0x61')][_0x58f0('0x69')],_['omit'](_0x91c507[_0x58f0('0x61')],['ids','id'])||{})[_0x58f0('0x8b')](function(_0x4951cf){for(var _0x1385e3=0x0;_0x1385e3<_0x91c507[_0x58f0('0x61')][_0x58f0('0x69')]['length'];_0x1385e3+=0x1){socket[_0x58f0('0xad')](_0x58f0('0xae'),{'UserId':Number(_0x91c507['body']['ids'][_0x1385e3]),'OpenchannelAccountId':Number(_0x91c507[_0x58f0('0x59')]['id'])});}return _0x4951cf;});}})['then'](respondWithResult(_0x2cdd80,null))['catch'](handleError(_0x2cdd80,null));};exports[_0x58f0('0xaf')]=function(_0x1db992,_0x567f43,_0x1ef876){return db[_0x58f0('0x54')]['find']({'where':{'id':_0x1db992[_0x58f0('0x59')]['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x567f43,null))[_0x58f0('0x38')](function(_0x52dba2){if(_0x52dba2){return _0x52dba2['removeAgents'](_0x1db992[_0x58f0('0x46')]['ids'])[_0x58f0('0x38')](function(){if(_[_0x58f0('0xb0')](_0x1db992['query'][_0x58f0('0x69')])){for(var _0x36cf2b=0x0;_0x36cf2b<_0x1db992['query'][_0x58f0('0x69')]['length'];_0x36cf2b+=0x1){socket[_0x58f0('0xad')](_0x58f0('0xb1'),{'UserId':Number(_0x1db992['query'][_0x58f0('0x69')][_0x36cf2b]),'OpenchannelAccountId':Number(_0x1db992[_0x58f0('0x59')]['id'])});}}else{socket[_0x58f0('0xad')]('userOpenchannelAccount:remove',{'UserId':Number(_0x1db992['query'][_0x58f0('0x69')]),'OpenchannelAccountId':Number(_0x1db992[_0x58f0('0x59')]['id'])});}});}})[_0x58f0('0x38')](respondWithStatusCode(_0x567f43,null))[_0x58f0('0x2a')](handleError(_0x567f43,null));};exports[_0x58f0('0xb2')]=function(_0x100526,_0x34d7df,_0x297ce3){var _0x2b7f7a={};var _0x5bc936={};var _0x42a593;var _0x2de332;return db[_0x58f0('0x54')][_0x58f0('0x6c')]({'where':{'id':_0x100526[_0x58f0('0x59')]['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x34d7df,null))[_0x58f0('0x38')](function(_0x21f134){if(_0x21f134){_0x42a593=_0x21f134;_0x5bc936[_0x58f0('0x44')]=_['keys'](db['User']['rawAttributes']);_0x5bc936[_0x58f0('0x46')]=_[_0x58f0('0x47')](_0x100526[_0x58f0('0x46')]);_0x5bc936[_0x58f0('0x50')]=_['intersection'](_0x5bc936[_0x58f0('0x44')],_0x5bc936[_0x58f0('0x46')]);_0x2b7f7a[_0x58f0('0x49')]=_[_0x58f0('0x48')](_0x5bc936[_0x58f0('0x44')],qs['fields'](_0x100526[_0x58f0('0x46')][_0x58f0('0x4a')]));_0x2b7f7a['attributes']=_0x2b7f7a[_0x58f0('0x49')][_0x58f0('0x65')]?_0x2b7f7a['attributes']:_0x5bc936[_0x58f0('0x44')];_0x2b7f7a[_0x58f0('0x4d')]=qs['sort'](_0x100526[_0x58f0('0x46')][_0x58f0('0x4e')]);_0x2b7f7a[_0x58f0('0x4f')]=qs[_0x58f0('0x50')](_[_0x58f0('0x6d')](_0x100526[_0x58f0('0x46')],_0x5bc936[_0x58f0('0x50')]));if(_0x100526['query'][_0x58f0('0x51')]){_0x2b7f7a[_0x58f0('0x4f')]=_['merge'](_0x2b7f7a[_0x58f0('0x4f')],{'$or':_['map'](_0x2b7f7a['attributes'],function(_0x54b024){var _0x4caa27={};_0x4caa27[_0x54b024]={'$like':'%'+_0x100526[_0x58f0('0x46')][_0x58f0('0x51')]+'%'};return _0x4caa27;})});}_0x2b7f7a=_[_0x58f0('0x52')]({},_0x2b7f7a,_0x100526['options']);return _0x42a593['getAgents'](_0x2b7f7a);}})[_0x58f0('0x38')](function(_0x3f0bf8){if(_0x3f0bf8){_0x2de332=_0x3f0bf8[_0x58f0('0x65')];if(!_0x100526['query']['hasOwnProperty'](_0x58f0('0x4b'))){_0x2b7f7a['limit']=qs[_0x58f0('0x4c')](_0x100526[_0x58f0('0x46')][_0x58f0('0x4c')]);_0x2b7f7a[_0x58f0('0x30')]=qs[_0x58f0('0x30')](_0x100526['query'][_0x58f0('0x30')]);}return _0x42a593[_0x58f0('0xb2')](_0x2b7f7a);}})['then'](function(_0xac19a3){if(_0xac19a3){return _0xac19a3?{'count':_0x2de332,'rows':_0xac19a3}:null;}})[_0x58f0('0x38')](respondWithResult(_0x34d7df,null))[_0x58f0('0x2a')](handleError(_0x34d7df,null));};exports[_0x58f0('0x3e')]=function(_0x400513,_0x4d83f7,_0x19dd80){var _0x371057,_0xc72729,_0xdbf418;if(_[_0x58f0('0x77')](_0x400513[_0x58f0('0x61')][_0x58f0('0x61')])||_0x400513[_0x58f0('0x61')][_0x58f0('0x61')]===''){throw new db[(_0x58f0('0x71'))][(_0x58f0('0x72'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x58f0('0x77')](_0x400513[_0x58f0('0x61')]['to'])){}_0x371057=_0x400513[_0x58f0('0x61')]['to'];return db['OpenchannelAccount']['findOne']({'where':{'id':_0x400513[_0x58f0('0x59')]['id']}})[_0x58f0('0x38')](handleEntityNotFound(_0x4d83f7,null))[_0x58f0('0x38')](function(_0x2d999b){if(_0x2d999b){return db[_0x58f0('0x54')][_0x58f0('0x5b')]({'where':{'id':_0x2d999b['id']},'include':[{'model':db[_0x58f0('0xb3')],'as':'List','include':[{'model':db[_0x58f0('0x70')],'as':'Contacts','where':{[_0x2d999b[_0x58f0('0x79')]]:_0x371057},'limit':0x1,'order':[['updatedAt',_0x58f0('0xb4')]]}]}]})[_0x58f0('0x38')](handleEntityNotFound(_0x4d83f7,null))[_0x58f0('0x38')](function(_0x2f7e06){if(_0x2f7e06&&_0x2f7e06[_0x58f0('0x7d')]){_0xc72729=_0x2f7e06[_0x58f0('0x3a')]({'plain':!![]});if(_0xc72729['List']&&_0xc72729[_0x58f0('0x7d')][_0x58f0('0x7e')][_0x58f0('0x65')]){return _0xc72729[_0x58f0('0x7d')][_0x58f0('0x7e')][0x0];}return db[_0x58f0('0x70')]['create'](_[_0x58f0('0x1a')](_0x400513['body'],{'firstName':_0x371057,[_0x2f7e06[_0x58f0('0x79')]]:_0x371057,'phone':_0x371057,'ListId':_0xc72729[_0x58f0('0x85')]}));}})[_0x58f0('0x38')](handleEntityNotFound(_0x4d83f7,null))[_0x58f0('0x38')](function(_0x8c2f40){if(_0x8c2f40){_0xdbf418=_0x8c2f40;return db[_0x58f0('0x89')][_0x58f0('0x5b')]({'where':{'ContactId':_0xdbf418['id'],'closed':![],'OpenchannelAccountId':_0xc72729['id']}})['then'](function(_0x59db58){if(_0x59db58){return[_0x59db58,![]];}return db[_0x58f0('0x89')]['create']({'UserId':_0x400513[_0x58f0('0x5d')]['id'],'ContactId':_0xdbf418['id'],'OpenchannelAccountId':_0xc72729['id'],'lastMsgDirection':_0x58f0('0xb5'),'Messages':[_[_0x58f0('0x52')](_0x400513[_0x58f0('0x61')],{'read':![],'body':_0x400513['body']['body'],'OpenchannelAccountId':_0xc72729['id'],'UserId':_0x400513[_0x58f0('0x5d')]['id'],'ContactId':_0xdbf418['id']})]},{'include':[{'model':db[_0x58f0('0x94')],'as':'Messages'}]})['then'](function(_0x158408){return[_0x158408,!![]];});});}})['spread'](function(_0x238b94,_0x526dbd){if(_0x526dbd){return _0x238b94;}return db['OpenchannelMessage'][_0x58f0('0x5c')](_['merge'](_0x400513[_0x58f0('0x61')],{'read':![],'body':_0x400513[_0x58f0('0x61')]['body'],'OpenchannelAccountId':_0xc72729['id'],'OpenchannelInteractionId':_0x238b94['id'],'UserId':_0x400513[_0x58f0('0x5d')]['id'],'ContactId':_0xdbf418['id']}))['then'](function(_0x3ef376){_0x238b94[_0x58f0('0xb6')][_0x58f0('0xb7')]=[];_0x238b94['dataValues'][_0x58f0('0xb7')]['push'](_0x3ef376[_0x58f0('0xb6')]);return _0x238b94;});});}})[_0x58f0('0x38')](respondWithResult(_0x4d83f7,null))[_0x58f0('0x2a')](handleError(_0x4d83f7,null));};
\ No newline at end of file
+var _0x5243=['count','includeAll','findAll','rows','show','params','keys','rawAttributes','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','Pause','destroy','describe','addDisposition','OpenchannelAccountId','Disposition','findOne','nolimit','include','removeDispositions','ids','addAnswer','CannedAnswer','removeAnswers','notify','openchannel','CmContact','ValidationError','difference','createdAt','updatedAt','ListId','isNil','Sequelize','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','CmList','List','Contacts','DESC','OpenchannelApplication','Applications','applications','orderBy','priority','account','contact','lastName','threadId','externalUrl','OpenchannelInteraction','ContactId','spread','firstName','messageId','interaction','created','autoclose','push','unmanaged','OpenchannelMessage','AttachmentId','User','UserId','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','bulkCreate','findAndCountAll','stack','getApplications','Owner','fullname','internal','Tags','color','tag','addAgents','omit','emit','userOpenchannelAccount:save','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','defaults','user','out','dataValues','Messages','eml-format','fast-json-patch','request-promise','mustache','util','sox','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','socket.io-emitter','redis','register','jayson/promise','client','http','request','then','info','OpenchannelAccount,\x20%s,\x20%s','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','json','offset','limit','undefined','set','reject','save','update','OpenchannelAccounts','UserProfileResource','end','name','send','index','mandatoryDispositionPause','map','OpenchannelAccount','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options'];(function(_0x5ae300,_0x382ca6){var _0x3460dc=function(_0x1359d1){while(--_0x1359d1){_0x5ae300['push'](_0x5ae300['shift']());}};_0x3460dc(++_0x382ca6);}(_0x5243,0x71));var _0x3524=function(_0x51a87a,_0x454399){_0x51a87a=_0x51a87a-0x0;var _0x44acde=_0x5243[_0x51a87a];return _0x44acde;};'use strict';var emlformat=require(_0x3524('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x3524('0x1'));var rp=require(_0x3524('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x3524('0x3'));var util=require(_0x3524('0x4'));var path=require('path');var sox=require(_0x3524('0x5'));var csv=require('to-csv');var ejs=require(_0x3524('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x3524('0x7'));var squel=require(_0x3524('0x8'));var crypto=require(_0x3524('0x9'));var jsforce=require(_0x3524('0xa'));var deskjs=require(_0x3524('0xb'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x3524('0xc'));var Redis=require(_0x3524('0xd'));var authService=require(_0x3524('0xe'));var qs=require(_0x3524('0xf'));var as=require(_0x3524('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x3524('0x11'))(_0x3524('0x12'));var utils=require('../../config/utils');var config=require(_0x3524('0x13'));var licenseUtil=require(_0x3524('0x14'));var db=require(_0x3524('0x15'))['db'];config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x3524('0x16'))(new Redis(config[_0x3524('0x17')]));require('./openchannelAccount.socket')[_0x3524('0x18')](socket);var jayson=require(_0x3524('0x19'));var client=jayson[_0x3524('0x1a')][_0x3524('0x1b')]({'port':0x232c});var client9002=jayson[_0x3524('0x1a')][_0x3524('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x34d9a0,_0x8440a4,_0x299449,_0x565fec){return new BPromise(function(_0x13e951,_0x491a6b){var _0x2eb681=_0x565fec||client;return _0x2eb681[_0x3524('0x1c')](_0x34d9a0,_0x299449)[_0x3524('0x1d')](function(_0x257048){logger[_0x3524('0x1e')](_0x3524('0x1f'),_0x8440a4,'request\x20sent');logger['debug'](_0x3524('0x20'),_0x8440a4,'request\x20sent',JSON[_0x3524('0x21')](_0x257048));if(_0x257048[_0x3524('0x22')]){if(_0x257048[_0x3524('0x22')][_0x3524('0x23')]===0x1f4){logger[_0x3524('0x22')](_0x3524('0x1f'),_0x8440a4,_0x257048['error'][_0x3524('0x24')]);return _0x491a6b(_0x257048[_0x3524('0x22')][_0x3524('0x24')]);}logger[_0x3524('0x22')](_0x3524('0x1f'),_0x8440a4,_0x257048['error'][_0x3524('0x24')]);return _0x13e951(_0x257048['error'][_0x3524('0x24')]);}else{logger[_0x3524('0x1e')](_0x3524('0x1f'),_0x8440a4,'request\x20sent');_0x13e951(_0x257048[_0x3524('0x25')][_0x3524('0x24')]);}})[_0x3524('0x26')](function(_0x27bd6a){logger['error'](_0x3524('0x1f'),_0x8440a4,_0x27bd6a);_0x491a6b(_0x27bd6a);});});}function respondWithStatusCode(_0x2271c9,_0x1765a4){_0x1765a4=_0x1765a4||0xcc;return function(_0x5dc071){if(_0x5dc071){return _0x2271c9[_0x3524('0x27')](_0x1765a4);}return _0x2271c9[_0x3524('0x28')](_0x1765a4)['end']();};}function respondWithResult(_0x143fbe,_0x3001ea){_0x3001ea=_0x3001ea||0xc8;return function(_0x564bf6){if(_0x564bf6){return _0x143fbe['status'](_0x3001ea)[_0x3524('0x29')](_0x564bf6);}};}function respondWithFilteredResult(_0x3fddc1,_0x225b26){return function(_0x651f11){if(_0x651f11){var _0x5bf38e=typeof _0x225b26[_0x3524('0x2a')]==='undefined'&&typeof _0x225b26[_0x3524('0x2b')]===_0x3524('0x2c');var _0xdfd937=_0x651f11['count'];var _0x55c1f7=_0x5bf38e?0x0:_0x225b26[_0x3524('0x2a')];var _0x3a0978=_0x5bf38e?_0x651f11['count']:_0x225b26[_0x3524('0x2a')]+_0x225b26[_0x3524('0x2b')];var _0x125329;if(_0x3a0978>=_0xdfd937){_0x3a0978=_0xdfd937;_0x125329=0xc8;}else{_0x125329=0xce;}_0x3fddc1[_0x3524('0x28')](_0x125329);return _0x3fddc1[_0x3524('0x2d')]('Content-Range',_0x55c1f7+'-'+_0x3a0978+'/'+_0xdfd937)[_0x3524('0x29')](_0x651f11);}return null;};}function patchUpdates(_0x1ef849){return function(_0xd98275){try{jsonpatch['apply'](_0xd98275,_0x1ef849,!![]);}catch(_0x3a3753){return BPromise[_0x3524('0x2e')](_0x3a3753);}return _0xd98275[_0x3524('0x2f')]();};}function saveUpdates(_0x2c9425,_0x1b7b9b){return function(_0xf89fc5){if(_0xf89fc5){return _0xf89fc5[_0x3524('0x30')](_0x2c9425)[_0x3524('0x1d')](function(_0x8c8edb){return _0x8c8edb;});}return null;};}function removeEntity(_0x4284d,_0xfea364){return function(_0x5bc684){if(_0x5bc684){return _0x5bc684['destroy']()['then'](function(){var _0x197f78=_0x5bc684['get']({'plain':!![]});var _0x8c086d=_0x3524('0x31');return db[_0x3524('0x32')]['destroy']({'where':{'type':_0x8c086d,'resourceId':_0x197f78['id']}})[_0x3524('0x1d')](function(){return _0x5bc684;});})['then'](function(){_0x4284d[_0x3524('0x28')](0xcc)[_0x3524('0x33')]();});}};}function handleEntityNotFound(_0x1ef552,_0xd1e02a){return function(_0x3f2d8c){if(!_0x3f2d8c){_0x1ef552['sendStatus'](0x194);}return _0x3f2d8c;};}function handleError(_0x1f87e3,_0x1d263f){_0x1d263f=_0x1d263f||0x1f4;return function(_0x8f6648){logger[_0x3524('0x22')](_0x8f6648['stack']);if(_0x8f6648[_0x3524('0x34')]){delete _0x8f6648[_0x3524('0x34')];}_0x1f87e3[_0x3524('0x28')](_0x1d263f)[_0x3524('0x35')](_0x8f6648);};}exports[_0x3524('0x36')]=function(_0x4c4166,_0x47f570){var _0x1ca407={'include':[{'model':db['Pause'],'as':_0x3524('0x37')}]},_0x122d39={},_0x18662e={'count':0x0,'rows':[]};var _0x214c41=_[_0x3524('0x38')](db[_0x3524('0x39')]['rawAttributes'],function(_0x3f6a24){return{'name':_0x3f6a24[_0x3524('0x3a')],'type':_0x3f6a24[_0x3524('0x3b')][_0x3524('0x3c')]};});_0x122d39[_0x3524('0x3d')]=_[_0x3524('0x38')](_0x214c41,'name');_0x122d39['query']=_['keys'](_0x4c4166[_0x3524('0x3e')]);_0x122d39[_0x3524('0x3f')]=_[_0x3524('0x40')](_0x122d39[_0x3524('0x3d')],_0x122d39[_0x3524('0x3e')]);_0x1ca407['attributes']=_[_0x3524('0x40')](_0x122d39[_0x3524('0x3d')],qs[_0x3524('0x41')](_0x4c4166[_0x3524('0x3e')][_0x3524('0x41')]));_0x1ca407[_0x3524('0x42')]=_0x1ca407[_0x3524('0x42')][_0x3524('0x43')]?_0x1ca407['attributes']:_0x122d39['model'];if(!_0x4c4166[_0x3524('0x3e')][_0x3524('0x44')]('nolimit')){_0x1ca407[_0x3524('0x2b')]=qs['limit'](_0x4c4166[_0x3524('0x3e')][_0x3524('0x2b')]);_0x1ca407[_0x3524('0x2a')]=qs[_0x3524('0x2a')](_0x4c4166[_0x3524('0x3e')][_0x3524('0x2a')]);}_0x1ca407[_0x3524('0x45')]=qs[_0x3524('0x46')](_0x4c4166[_0x3524('0x3e')]['sort']);_0x1ca407[_0x3524('0x47')]=qs[_0x3524('0x3f')](_[_0x3524('0x48')](_0x4c4166['query'],_0x122d39[_0x3524('0x3f')]),_0x214c41);if(_0x4c4166['query'][_0x3524('0x49')]){_0x1ca407[_0x3524('0x47')]=_[_0x3524('0x4a')](_0x1ca407[_0x3524('0x47')],{'$or':_[_0x3524('0x38')](_0x214c41,function(_0x2d4604){if(_0x2d4604[_0x3524('0x3b')]!==_0x3524('0x4b')){var _0x31390e={};_0x31390e[_0x2d4604[_0x3524('0x34')]]={'$like':'%'+_0x4c4166[_0x3524('0x3e')]['filter']+'%'};return _0x31390e;}})});}_0x1ca407=_['merge']({},_0x1ca407,_0x4c4166[_0x3524('0x4c')]);var _0x333fcc={'where':_0x1ca407[_0x3524('0x47')]};return db[_0x3524('0x39')][_0x3524('0x4d')](_0x333fcc)[_0x3524('0x1d')](function(_0x8b77dd){_0x18662e[_0x3524('0x4d')]=_0x8b77dd;if(_0x4c4166[_0x3524('0x3e')][_0x3524('0x4e')]){_0x1ca407['include']=[{'all':!![]}];}return db[_0x3524('0x39')][_0x3524('0x4f')](_0x1ca407);})[_0x3524('0x1d')](function(_0x2afe3a){_0x18662e[_0x3524('0x50')]=_0x2afe3a;return _0x18662e;})[_0x3524('0x1d')](respondWithFilteredResult(_0x47f570,_0x1ca407))[_0x3524('0x26')](handleError(_0x47f570,null));};exports[_0x3524('0x51')]=function(_0x166c23,_0x3ec212){var _0x4fa3d3={'raw':![],'where':{'id':_0x166c23[_0x3524('0x52')]['id']},'include':[{'model':db['Pause'],'as':_0x3524('0x37')}]},_0x403639={};_0x403639[_0x3524('0x3d')]=_[_0x3524('0x53')](db['OpenchannelAccount'][_0x3524('0x54')]);_0x403639['query']=_[_0x3524('0x53')](_0x166c23['query']);_0x403639[_0x3524('0x3f')]=_[_0x3524('0x40')](_0x403639[_0x3524('0x3d')],_0x403639[_0x3524('0x3e')]);_0x4fa3d3['attributes']=_[_0x3524('0x40')](_0x403639[_0x3524('0x3d')],qs['fields'](_0x166c23['query']['fields']));_0x4fa3d3['attributes']=_0x4fa3d3[_0x3524('0x42')]['length']?_0x4fa3d3[_0x3524('0x42')]:_0x403639[_0x3524('0x3d')];if(_0x166c23[_0x3524('0x3e')][_0x3524('0x4e')]){_0x4fa3d3['include']=[{'all':!![]}];}_0x4fa3d3=_[_0x3524('0x4a')]({},_0x4fa3d3,_0x166c23[_0x3524('0x4c')]);return db[_0x3524('0x39')]['find'](_0x4fa3d3)['then'](handleEntityNotFound(_0x3ec212,null))[_0x3524('0x1d')](respondWithResult(_0x3ec212,null))[_0x3524('0x26')](handleError(_0x3ec212,null));};exports[_0x3524('0x55')]=function(_0x2105f3,_0x1a9744){return db[_0x3524('0x39')][_0x3524('0x55')](_0x2105f3[_0x3524('0x56')],{})[_0x3524('0x1d')](function(_0x5a32b0){var _0x336896=_0x2105f3['user'][_0x3524('0x57')]({'plain':!![]});if(!_0x336896)throw new Error(_0x3524('0x58'));if(_0x336896[_0x3524('0x59')]==='user'){var _0x4293c1=_0x5a32b0[_0x3524('0x57')]({'plain':!![]});var _0x4c7a10=_0x3524('0x31');return db[_0x3524('0x5a')]['find']({'where':{'name':_0x4c7a10,'userProfileId':_0x336896[_0x3524('0x5b')]},'raw':!![]})[_0x3524('0x1d')](function(_0x52ff61){if(_0x52ff61&&_0x52ff61[_0x3524('0x5c')]===0x0){return db[_0x3524('0x32')][_0x3524('0x55')]({'name':_0x4293c1[_0x3524('0x34')],'resourceId':_0x4293c1['id'],'type':_0x52ff61[_0x3524('0x34')],'sectionId':_0x52ff61['id']},{})[_0x3524('0x1d')](function(){return _0x5a32b0;});}else{return _0x5a32b0;}})['catch'](function(_0x1ce531){logger[_0x3524('0x22')](_0x3524('0x5d'),_0x1ce531);throw _0x1ce531;});}return _0x5a32b0;})[_0x3524('0x1d')](respondWithResult(_0x1a9744,0xc9))[_0x3524('0x26')](handleError(_0x1a9744,null));};exports[_0x3524('0x30')]=function(_0xc073a9,_0x5814fd){if(_0xc073a9['body']['id']){delete _0xc073a9[_0x3524('0x56')]['id'];}return db['OpenchannelAccount'][_0x3524('0x5e')]({'where':{'id':_0xc073a9[_0x3524('0x52')]['id']},'include':[{'model':db[_0x3524('0x5f')],'as':_0x3524('0x37')}]})[_0x3524('0x1d')](handleEntityNotFound(_0x5814fd,null))['then'](saveUpdates(_0xc073a9['body'],null))[_0x3524('0x1d')](respondWithResult(_0x5814fd,null))[_0x3524('0x26')](handleError(_0x5814fd,null));};exports[_0x3524('0x60')]=function(_0x59fe1e,_0x1f9820){return db[_0x3524('0x39')][_0x3524('0x5e')]({'where':{'id':_0x59fe1e[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x1f9820,null))[_0x3524('0x1d')](removeEntity(_0x1f9820,null))['catch'](handleError(_0x1f9820,null));};exports['describe']=function(_0x22ae88,_0x3e46f1){return db[_0x3524('0x39')][_0x3524('0x61')]()['then'](respondWithResult(_0x3e46f1,null))['catch'](handleError(_0x3e46f1,null));};exports[_0x3524('0x62')]=function(_0x3a068a,_0x206569,_0x34e3f8){if(_0x3a068a[_0x3524('0x56')]['id']){delete _0x3a068a[_0x3524('0x56')]['id'];}return db[_0x3524('0x39')][_0x3524('0x5e')]({'where':{'id':_0x3a068a[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x206569,null))[_0x3524('0x1d')](function(_0x104d35){if(_0x104d35){_0x3a068a['body'][_0x3524('0x63')]=_0x104d35['id'];return db[_0x3524('0x64')][_0x3524('0x55')](_0x3a068a[_0x3524('0x56')]);}})[_0x3524('0x1d')](respondWithResult(_0x206569,null))[_0x3524('0x26')](handleError(_0x206569,null));};exports['getDispositions']=function(_0x2a56bf,_0x204e46,_0x2e14b9){var _0x1ea63c={'raw':![],'where':{}};var _0x1c4fa1={};var _0x4691d1={'count':0x0,'rows':[]};return db[_0x3524('0x39')][_0x3524('0x65')]({'where':{'id':_0x2a56bf[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x204e46,null))[_0x3524('0x1d')](function(_0xd91ee6){if(_0xd91ee6){_0x1c4fa1[_0x3524('0x3d')]=_['keys'](db[_0x3524('0x64')][_0x3524('0x54')]);_0x1c4fa1['query']=_[_0x3524('0x53')](_0x2a56bf['query']);_0x1c4fa1[_0x3524('0x3f')]=_['intersection'](_0x1c4fa1['model'],_0x1c4fa1['query']);_0x1ea63c[_0x3524('0x42')]=_['intersection'](_0x1c4fa1[_0x3524('0x3d')],qs[_0x3524('0x41')](_0x2a56bf[_0x3524('0x3e')]['fields']));_0x1ea63c['attributes']=_0x1ea63c[_0x3524('0x42')][_0x3524('0x43')]?_0x1ea63c[_0x3524('0x42')]:_0x1c4fa1[_0x3524('0x3d')];if(!_0x2a56bf[_0x3524('0x3e')][_0x3524('0x44')](_0x3524('0x66'))){_0x1ea63c['limit']=qs[_0x3524('0x2b')](_0x2a56bf[_0x3524('0x3e')][_0x3524('0x2b')]);_0x1ea63c[_0x3524('0x2a')]=qs[_0x3524('0x2a')](_0x2a56bf[_0x3524('0x3e')]['offset']);}_0x1ea63c[_0x3524('0x45')]=qs[_0x3524('0x46')](_0x2a56bf[_0x3524('0x3e')][_0x3524('0x46')]);_0x1ea63c[_0x3524('0x47')]=qs[_0x3524('0x3f')](_[_0x3524('0x48')](_0x2a56bf['query'],_0x1c4fa1[_0x3524('0x3f')]));_0x1ea63c[_0x3524('0x47')]['OpenchannelAccountId']=_0xd91ee6['id'];if(_0x2a56bf['query'][_0x3524('0x49')]){_0x1ea63c[_0x3524('0x47')]=_[_0x3524('0x4a')](_0x1ea63c[_0x3524('0x47')],{'$or':_[_0x3524('0x38')](_0x1ea63c['attributes'],function(_0x4e590){var _0xe0e86={};_0xe0e86[_0x4e590]={'$like':'%'+_0x2a56bf[_0x3524('0x3e')]['filter']+'%'};return _0xe0e86;})});}_0x1ea63c=_[_0x3524('0x4a')]({},_0x1ea63c,_0x2a56bf['options']);return db[_0x3524('0x64')]['count']({'where':_0x1ea63c[_0x3524('0x47')]})['then'](function(_0xdeb58f){_0x4691d1[_0x3524('0x4d')]=_0xdeb58f;if(_0x2a56bf[_0x3524('0x3e')][_0x3524('0x4e')]){_0x1ea63c[_0x3524('0x67')]=[{'all':!![]}];}return db[_0x3524('0x64')][_0x3524('0x4f')](_0x1ea63c);})[_0x3524('0x1d')](function(_0x4b4547){_0x4691d1['rows']=_0x4b4547;return _0x4691d1;});}})[_0x3524('0x1d')](respondWithFilteredResult(_0x204e46,_0x1ea63c))[_0x3524('0x26')](handleError(_0x204e46,null));};exports['removeDispositions']=function(_0x5aeedb,_0x5aa253,_0x247260){return db[_0x3524('0x39')][_0x3524('0x5e')]({'where':{'id':_0x5aeedb['params']['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x5aa253,null))[_0x3524('0x1d')](function(_0x49d2ed){if(_0x49d2ed){return _0x49d2ed[_0x3524('0x68')](_0x5aeedb[_0x3524('0x3e')][_0x3524('0x69')]);}})[_0x3524('0x1d')](respondWithStatusCode(_0x5aa253,null))[_0x3524('0x26')](handleError(_0x5aa253,null));};exports[_0x3524('0x6a')]=function(_0x5be37b,_0x370175,_0x33c182){if(_0x5be37b[_0x3524('0x56')]['id']){delete _0x5be37b['body']['id'];}return db['OpenchannelAccount'][_0x3524('0x5e')]({'where':{'id':_0x5be37b['params']['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x370175,null))[_0x3524('0x1d')](function(_0xbb01ff){if(_0xbb01ff){_0x5be37b[_0x3524('0x56')][_0x3524('0x63')]=_0xbb01ff['id'];return db['CannedAnswer'][_0x3524('0x55')](_0x5be37b[_0x3524('0x56')]);}})[_0x3524('0x1d')](respondWithResult(_0x370175,null))['catch'](handleError(_0x370175,null));};exports['getAnswers']=function(_0x952af,_0x22ba0b,_0x49653c){var _0x456b06={'raw':![],'where':{}};var _0x1f2cc5={};var _0x10e631={'count':0x0,'rows':[]};return db[_0x3524('0x39')][_0x3524('0x65')]({'where':{'id':_0x952af[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x22ba0b,null))[_0x3524('0x1d')](function(_0x5ea5c2){if(_0x5ea5c2){_0x1f2cc5[_0x3524('0x3d')]=_[_0x3524('0x53')](db[_0x3524('0x6b')][_0x3524('0x54')]);_0x1f2cc5['query']=_[_0x3524('0x53')](_0x952af[_0x3524('0x3e')]);_0x1f2cc5['filters']=_['intersection'](_0x1f2cc5[_0x3524('0x3d')],_0x1f2cc5[_0x3524('0x3e')]);_0x456b06[_0x3524('0x42')]=_[_0x3524('0x40')](_0x1f2cc5[_0x3524('0x3d')],qs[_0x3524('0x41')](_0x952af['query'][_0x3524('0x41')]));_0x456b06['attributes']=_0x456b06[_0x3524('0x42')][_0x3524('0x43')]?_0x456b06[_0x3524('0x42')]:_0x1f2cc5['model'];if(!_0x952af[_0x3524('0x3e')][_0x3524('0x44')](_0x3524('0x66'))){_0x456b06[_0x3524('0x2b')]=qs['limit'](_0x952af[_0x3524('0x3e')][_0x3524('0x2b')]);_0x456b06[_0x3524('0x2a')]=qs['offset'](_0x952af['query'][_0x3524('0x2a')]);}_0x456b06[_0x3524('0x45')]=qs[_0x3524('0x46')](_0x952af[_0x3524('0x3e')][_0x3524('0x46')]);_0x456b06[_0x3524('0x47')]=qs['filters'](_[_0x3524('0x48')](_0x952af[_0x3524('0x3e')],_0x1f2cc5[_0x3524('0x3f')]));_0x456b06[_0x3524('0x47')][_0x3524('0x63')]=_0x5ea5c2['id'];if(_0x952af[_0x3524('0x3e')][_0x3524('0x49')]){_0x456b06[_0x3524('0x47')]=_[_0x3524('0x4a')](_0x456b06[_0x3524('0x47')],{'$or':_[_0x3524('0x38')](_0x456b06[_0x3524('0x42')],function(_0x56fbba){var _0x45ee7d={};_0x45ee7d[_0x56fbba]={'$like':'%'+_0x952af[_0x3524('0x3e')][_0x3524('0x49')]+'%'};return _0x45ee7d;})});}_0x456b06=_[_0x3524('0x4a')]({},_0x456b06,_0x952af['options']);return db['CannedAnswer'][_0x3524('0x4d')]({'where':_0x456b06['where']})[_0x3524('0x1d')](function(_0x207e3b){_0x10e631[_0x3524('0x4d')]=_0x207e3b;if(_0x952af[_0x3524('0x3e')]['includeAll']){_0x456b06[_0x3524('0x67')]=[{'all':!![]}];}return db[_0x3524('0x6b')][_0x3524('0x4f')](_0x456b06);})[_0x3524('0x1d')](function(_0x1cfb89){_0x10e631['rows']=_0x1cfb89;return _0x10e631;});}})[_0x3524('0x1d')](respondWithFilteredResult(_0x22ba0b,_0x456b06))[_0x3524('0x26')](handleError(_0x22ba0b,null));};exports[_0x3524('0x6c')]=function(_0x211019,_0x2d03e6,_0x52b5f1){return db[_0x3524('0x39')][_0x3524('0x5e')]({'where':{'id':_0x211019[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x2d03e6,null))[_0x3524('0x1d')](function(_0x4936a7){if(_0x4936a7){return _0x4936a7[_0x3524('0x6c')](_0x211019[_0x3524('0x3e')]['ids']);}})[_0x3524('0x1d')](respondWithStatusCode(_0x2d03e6,null))[_0x3524('0x26')](handleError(_0x2d03e6,null));};exports[_0x3524('0x6d')]=function(_0x1a1421,_0x270d06,_0x5dc5ed){var _0x2026fc={'body':_0x1a1421[_0x3524('0x56')],'channel':_0x3524('0x6e')};var _0x58d54f=[];var _0x5d06c4=[];var _0x2c5303={};var _0x3c7836=![];return db[_0x3524('0x6f')][_0x3524('0x61')]()[_0x3524('0x1d')](function(_0x27ee35){if(!_0x27ee35){throw new db['Sequelize'][(_0x3524('0x70'))]('no\x20available\x20attributes');}_0x58d54f=_[_0x3524('0x71')](_[_0x3524('0x53')](_0x27ee35),[_0x3524('0x72'),_0x3524('0x73')]);_0x5d06c4=_[_0x3524('0x71')](_['keys'](_0x27ee35),['createdAt',_0x3524('0x73'),'CompanyId',_0x3524('0x74')]);if(_0x1a1421['body']['id']){delete _0x1a1421[_0x3524('0x56')]['id'];}if(_[_0x3524('0x75')](_0x1a1421[_0x3524('0x56')]['from'])){throw new db[(_0x3524('0x76'))]['ValidationError'](_0x3524('0x77'));}if(_[_0x3524('0x75')](_0x1a1421[_0x3524('0x56')][_0x3524('0x56')])||_0x1a1421[_0x3524('0x56')]['body']===''){throw new db[(_0x3524('0x76'))][(_0x3524('0x70'))](_0x3524('0x78'));}if(_[_0x3524('0x75')](_0x1a1421['body'][_0x3524('0x79')])){throw new db[(_0x3524('0x76'))][(_0x3524('0x70'))](_0x3524('0x7a')+_0x5d06c4);}if(!_[_0x3524('0x7b')](_0x5d06c4,_0x1a1421[_0x3524('0x56')][_0x3524('0x79')])){throw new db[(_0x3524('0x76'))]['ValidationError'](_0x3524('0x7c')+_0x5d06c4);}_0x2c5303[_0x1a1421[_0x3524('0x56')]['mapKey']]=_0x1a1421[_0x3524('0x56')][_0x3524('0x7d')];})[_0x3524('0x1d')](function(){return db[_0x3524('0x39')][_0x3524('0x5e')]({'where':{'id':_0x1a1421[_0x3524('0x52')]['id']},'include':[{'model':db[_0x3524('0x7e')],'as':_0x3524('0x7f'),'include':[{'model':db[_0x3524('0x6f')],'as':_0x3524('0x80'),'where':_0x2c5303,'limit':0x1,'order':[[_0x3524('0x73'),_0x3524('0x81')]]}]},{'model':db[_0x3524('0x82')],'as':_0x3524('0x83')}]});})[_0x3524('0x1d')](handleEntityNotFound(_0x270d06,null))['then'](function(_0xeb8d47){if(_0xeb8d47&&_0xeb8d47[_0x3524('0x7f')]){_0x2026fc['account']=_0xeb8d47;_0x2026fc[_0x3524('0x84')]=_0xeb8d47[_0x3524('0x83')];_0x2026fc['list']=_0xeb8d47[_0x3524('0x7f')];_0x2026fc[_0x3524('0x84')]=_[_0x3524('0x85')](_0x2026fc['applications'],[_0x3524('0x86')],['asc']);if(_0x2026fc[_0x3524('0x87')][_0x3524('0x83')]){delete _0x2026fc['account'][_0x3524('0x83')];}if(_0x2026fc[_0x3524('0x87')][_0x3524('0x7f')]&&_0x2026fc['account'][_0x3524('0x7f')]['Contacts'][_0x3524('0x43')]){return _0x2026fc[_0x3524('0x87')][_0x3524('0x7f')]['Contacts'][0x0];}var _0x3120f7=_['defaults'](_0x1a1421['body'],{'firstName':_0x1a1421[_0x3524('0x56')][_0x3524('0x7d')],'ListId':_0xeb8d47[_0x3524('0x74')]});_0x3120f7[_0x1a1421[_0x3524('0x56')]['mapKey']]=_0x1a1421['body'][_0x3524('0x7d')];return db['CmContact']['create'](_0x3120f7,{'fields':_0x58d54f,'raw':!![]});}})[_0x3524('0x1d')](handleEntityNotFound(_0x270d06,null))[_0x3524('0x1d')](function(_0x1b3b32){_0x2026fc[_0x3524('0x88')]=_0x1b3b32;if(_0x1b3b32){var _0x388fea={'ContactId':_0x1b3b32['id'],'OpenchannelAccountId':_0x1a1421[_0x3524('0x52')]['id'],'from':(_0x1b3b32['firstName']||'')+'\x20'+(_0x1b3b32[_0x3524('0x89')]||'')};var _0x275b5b={'OpenchannelAccountId':_0x1a1421[_0x3524('0x52')]['id'],'closed':![]};if(_0x1a1421['body']['threadId']){_0x275b5b['threadId']=_0x1a1421[_0x3524('0x56')]['threadId'];return db['OpenchannelInteraction'][_0x3524('0x5e')]({'where':_0x275b5b})['then'](function(_0x8462d9){if(_0x8462d9){return[_0x8462d9,![]];}_0x388fea[_0x3524('0x8a')]=_0x1a1421['body'][_0x3524('0x8a')];_0x388fea[_0x3524('0x8b')]=_0x1a1421[_0x3524('0x56')][_0x3524('0x8b')];return db[_0x3524('0x8c')][_0x3524('0x55')](_0x388fea)[_0x3524('0x1d')](function(_0x1fbba2){return[_0x1fbba2,!![]];});});}else{_0x275b5b[_0x3524('0x8a')]=null;}_0x275b5b[_0x3524('0x8d')]=_0x1b3b32['id'];return db['OpenchannelInteraction'][_0x3524('0x5e')]({'where':_0x275b5b})[_0x3524('0x1d')](function(_0x28dddd){if(_0x28dddd){return[_0x28dddd,![]];}return db['OpenchannelInteraction']['create'](_0x388fea)[_0x3524('0x1d')](function(_0x11cc1b){return[_0x11cc1b,!![]];});});}})[_0x3524('0x8e')](function(_0x1d3324,_0x48dbe0){if(_0x1d3324){_0x3c7836=_0x48dbe0;if(!_0x48dbe0){var _0x1806ef={'from':(_0x2026fc[_0x3524('0x88')][_0x3524('0x8f')]||'')+'\x20'+(_0x2026fc[_0x3524('0x88')][_0x3524('0x89')]||'')};if(_0x1a1421[_0x3524('0x56')]['threadId']&&_0x1a1421[_0x3524('0x56')][_0x3524('0x90')]&&_0x1a1421[_0x3524('0x56')]['threadId']!=_0x1a1421[_0x3524('0x56')][_0x3524('0x90')]){_0x1806ef[_0x3524('0x8a')]=_0x1a1421[_0x3524('0x56')][_0x3524('0x90')];}return _0x1d3324[_0x3524('0x30')](_0x1806ef);}else{return _0x1d3324;}}})[_0x3524('0x1d')](function(_0x5a6bfa){_0x2026fc[_0x3524('0x91')]=_0x5a6bfa['get']({'plain':!![]});_0x2026fc[_0x3524('0x91')][_0x3524('0x92')]=_0x3c7836;if(_0x2026fc[_0x3524('0x91')]['created']){if(_0x2026fc[_0x3524('0x87')][_0x3524('0x93')]){_0x2026fc[_0x3524('0x84')][_0x3524('0x94')]({'id':0x0,'priority':_0x2026fc[_0x3524('0x84')][_0x3524('0x43')]+0x1,'app':'close','appdata':_0x3524('0x95'),'interval':'*,*,*,*'});}}return db[_0x3524('0x96')][_0x3524('0x55')]({'body':_0x1a1421[_0x3524('0x56')]['body'],'OpenchannelAccountId':_0x1a1421[_0x3524('0x52')]['id'],'OpenchannelInteractionId':_0x5a6bfa['id'],'direction':'in','ContactId':_0x2026fc[_0x3524('0x88')]['id'],'AttachmentId':_0x1a1421[_0x3524('0x56')][_0x3524('0x97')]});})[_0x3524('0x1d')](function(_0x10a41f){_0x2026fc['message']=_0x10a41f;if(_0x2026fc[_0x3524('0x91')]['UserId']){return db[_0x3524('0x98')]['find']({'attributes':['id',_0x3524('0x34')],'where':{'id':_0x2026fc[_0x3524('0x91')][_0x3524('0x99')]}})[_0x3524('0x1d')](function(_0x517e2e){if(_0x517e2e){_0x2026fc[_0x3524('0x84')][_0x3524('0x9a')]({'id':0x0,'priority':0x0,'app':_0x3524('0x9b'),'appdata':_0x517e2e[_0x3524('0x34')]+','+(_0x2026fc[_0x3524('0x87')][_0x3524('0x9c')]||0xa),'interval':_0x3524('0x9d')});_0x2026fc[_0x3524('0x9e')]=![];}return respondWithRpcPromise(_0x3524('0x9f'),'startRouting',_0x2026fc);});}return respondWithRpcPromise('Start',_0x3524('0xa0'),_0x2026fc);})[_0x3524('0x1d')](function(_0x396943){respondWithRpcPromise(_0x3524('0xa1'),_0x3524('0xa1'),{'event':_0x3524('0x6d'),'message':_0x396943},client9002);return _0x396943;})['then'](respondWithResult(_0x270d06,null))[_0x3524('0x26')](handleError(_0x270d06,null));};exports['addApplications']=function(_0x52ed00,_0x2ffafe){var _0x5a3747=_0x52ed00[_0x3524('0x52')]['id'];var _0x590cff=_0x52ed00[_0x3524('0x56')];var _0xf0eab=0xc8;var _0x10d285=null;return db[_0x3524('0xa2')][_0x3524('0xa3')]({'isolationLevel':db[_0x3524('0xa2')][_0x3524('0xa4')][_0x3524('0xa5')][_0x3524('0xa6')]},function(_0x28b2b3){return db[_0x3524('0x39')][_0x3524('0x65')]({'where':{'id':_0x5a3747},'transaction':_0x28b2b3})[_0x3524('0x1d')](function(_0x3451f9){if(_0x3451f9){return db['OpenchannelApplication'][_0x3524('0x60')]({'where':{'OpenchannelAccountId':_0x5a3747},'transaction':_0x28b2b3})[_0x3524('0x1d')](function(){var _0x1aa935=_[_0x3524('0x38')](_0x590cff,function(_0x25adec){_0x25adec['OpenchannelAccountId']=_0x5a3747;return _0x25adec;});return db[_0x3524('0x82')][_0x3524('0xa7')](_0x1aa935,{'transaction':_0x28b2b3});});}else{_0xf0eab=0x194;_0x10d285=[];}});})[_0x3524('0x1d')](function(){if(_0xf0eab!==0x194){return db['OpenchannelApplication'][_0x3524('0xa8')]({'where':{'OpenchannelAccountId':_0x5a3747},'order':_0x3524('0x86')})[_0x3524('0x1d')](function(_0x1834e5){_0x10d285=_0x1834e5;});}})[_0x3524('0x26')](function(_0x528413){_0xf0eab=0x1f4;logger[_0x3524('0x22')](_0x528413[_0x3524('0xa9')]);if(_0x528413[_0x3524('0x34')]){delete _0x528413['name'];}_0x10d285=_0x528413;})['finally'](function(){if(_0x10d285===null){_0x2ffafe[_0x3524('0x27')](_0xf0eab);}else{if(_0xf0eab===0x1f4){_0x2ffafe[_0x3524('0x28')](_0xf0eab)['send'](_0x10d285);}else{_0x2ffafe[_0x3524('0x28')](_0xf0eab)[_0x3524('0x29')](_0x10d285);}}});};exports[_0x3524('0xaa')]=function(_0xc08236,_0x198c61,_0x28774c){var _0x4a599b={};var _0x40c3e5={};var _0x129e0c;var _0x177f8c;return db[_0x3524('0x39')][_0x3524('0x65')]({'where':{'id':_0xc08236[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x198c61,null))[_0x3524('0x1d')](function(_0x8f5316){if(_0x8f5316){_0x129e0c=_0x8f5316;_0x40c3e5[_0x3524('0x3d')]=_[_0x3524('0x53')](db[_0x3524('0x82')][_0x3524('0x54')]);_0x40c3e5['query']=_['keys'](_0xc08236[_0x3524('0x3e')]);_0x40c3e5[_0x3524('0x3f')]=_[_0x3524('0x40')](_0x40c3e5[_0x3524('0x3d')],_0x40c3e5[_0x3524('0x3e')]);_0x4a599b[_0x3524('0x42')]=_['intersection'](_0x40c3e5[_0x3524('0x3d')],qs[_0x3524('0x41')](_0xc08236['query'][_0x3524('0x41')]));_0x4a599b[_0x3524('0x42')]=_0x4a599b[_0x3524('0x42')][_0x3524('0x43')]?_0x4a599b[_0x3524('0x42')]:_0x40c3e5[_0x3524('0x3d')];_0x4a599b['order']=qs[_0x3524('0x46')](_0xc08236[_0x3524('0x3e')][_0x3524('0x46')]);_0x4a599b[_0x3524('0x47')]=qs['filters'](_['pick'](_0xc08236[_0x3524('0x3e')],_0x40c3e5[_0x3524('0x3f')]));if(_0xc08236[_0x3524('0x3e')]['filter']){_0x4a599b['where']=_[_0x3524('0x4a')](_0x4a599b[_0x3524('0x47')],{'$or':_[_0x3524('0x38')](_0x4a599b['attributes'],function(_0xed2558){var _0xa2c8eb={};_0xa2c8eb[_0xed2558]={'$like':'%'+_0xc08236[_0x3524('0x3e')][_0x3524('0x49')]+'%'};return _0xa2c8eb;})});}_0x4a599b=_[_0x3524('0x4a')]({},_0x4a599b,_0xc08236[_0x3524('0x4c')]);return _0x129e0c[_0x3524('0xaa')](_0x4a599b);}})['then'](function(_0x2cb9c8){if(_0x2cb9c8){_0x177f8c=_0x2cb9c8[_0x3524('0x43')];if(!_0xc08236[_0x3524('0x3e')][_0x3524('0x44')](_0x3524('0x66'))){_0x4a599b[_0x3524('0x2b')]=qs[_0x3524('0x2b')](_0xc08236[_0x3524('0x3e')][_0x3524('0x2b')]);_0x4a599b['offset']=qs[_0x3524('0x2a')](_0xc08236[_0x3524('0x3e')][_0x3524('0x2a')]);}return _0x129e0c[_0x3524('0xaa')](_0x4a599b);}})[_0x3524('0x1d')](function(_0x5c1de6){if(_0x5c1de6){return _0x5c1de6?{'count':_0x177f8c,'rows':_0x5c1de6}:null;}})['then'](respondWithResult(_0x198c61,null))['catch'](handleError(_0x198c61,null));};exports['getInteractions']=function(_0xc7b425,_0x3ee009,_0x32c9cc){var _0x25076f={'raw':![],'where':{}};var _0x596822={};var _0x17b46d={'count':0x0,'rows':[]};return db[_0x3524('0x39')][_0x3524('0x65')]({'where':{'id':_0xc7b425['params']['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x3ee009,null))[_0x3524('0x1d')](function(_0x9c8276){if(_0x9c8276){_0x596822[_0x3524('0x3d')]=_[_0x3524('0x53')](db[_0x3524('0x8c')][_0x3524('0x54')]);_0x596822[_0x3524('0x3e')]=_['keys'](_0xc7b425[_0x3524('0x3e')]);_0x596822[_0x3524('0x3f')]=_[_0x3524('0x40')](_0x596822[_0x3524('0x3d')],_0x596822[_0x3524('0x3e')]);_0x25076f['attributes']=_[_0x3524('0x40')](_0x596822[_0x3524('0x3d')],qs[_0x3524('0x41')](_0xc7b425[_0x3524('0x3e')][_0x3524('0x41')]));_0x25076f[_0x3524('0x42')]=_0x25076f[_0x3524('0x42')]['length']?_0x25076f[_0x3524('0x42')]:_0x596822[_0x3524('0x3d')];if(!_0xc7b425[_0x3524('0x3e')][_0x3524('0x44')](_0x3524('0x66'))){_0x25076f[_0x3524('0x2b')]=qs['limit'](_0xc7b425[_0x3524('0x3e')][_0x3524('0x2b')]);_0x25076f[_0x3524('0x2a')]=qs[_0x3524('0x2a')](_0xc7b425['query'][_0x3524('0x2a')]);}_0x25076f[_0x3524('0x45')]=qs['sort'](_0xc7b425[_0x3524('0x3e')][_0x3524('0x46')]);_0x25076f[_0x3524('0x47')]=qs[_0x3524('0x3f')](_[_0x3524('0x48')](_0xc7b425['query'],_0x596822['filters']));_0x25076f[_0x3524('0x47')][_0x3524('0x63')]=_0x9c8276['id'];if(_0xc7b425[_0x3524('0x3e')][_0x3524('0x49')]){_0x25076f[_0x3524('0x47')]=_[_0x3524('0x4a')](_0x25076f[_0x3524('0x47')],{'$or':_[_0x3524('0x38')](_0x25076f['attributes'],function(_0x37c006){var _0x159a34={};_0x159a34[_0x37c006]={'$like':'%'+_0xc7b425[_0x3524('0x3e')]['filter']+'%'};return _0x159a34;})});}_0x25076f=_[_0x3524('0x4a')]({},_0x25076f,_0xc7b425[_0x3524('0x4c')]);return db[_0x3524('0x8c')][_0x3524('0x4d')]({'where':_0x25076f['where']})[_0x3524('0x1d')](function(_0x37efc7){_0x17b46d[_0x3524('0x4d')]=_0x37efc7;if(_0xc7b425['query'][_0x3524('0x4e')]){_0x25076f[_0x3524('0x67')]=[{'model':db['CmContact'],'as':'Contact','required':![]},{'model':db[_0x3524('0x98')],'as':_0x3524('0xab'),'attributes':[_0x3524('0x34'),_0x3524('0xac'),_0x3524('0xad')],'required':![]},{'model':db['Tag'],'as':_0x3524('0xae'),'attributes':['id',_0x3524('0x34'),_0x3524('0xaf')],'where':_0xc7b425[_0x3524('0x3e')][_0x3524('0xb0')]?{'id':_0xc7b425[_0x3524('0x3e')]['tag']}:undefined,'required':_0xc7b425[_0x3524('0x3e')][_0x3524('0xb0')]?!![]:![]}];}return db[_0x3524('0x8c')][_0x3524('0x4f')](_0x25076f);})[_0x3524('0x1d')](function(_0x23c22a){_0x17b46d[_0x3524('0x50')]=_0x23c22a;return _0x17b46d;});}})[_0x3524('0x1d')](respondWithFilteredResult(_0x3ee009,_0x25076f))[_0x3524('0x26')](handleError(_0x3ee009,null));};exports[_0x3524('0xb1')]=function(_0x881a00,_0x3208a5,_0x4b2479){return db[_0x3524('0x39')]['find']({'where':{'id':_0x881a00[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x3208a5,null))[_0x3524('0x1d')](function(_0x40bf52){if(_0x40bf52){return _0x40bf52[_0x3524('0xb1')](_0x881a00[_0x3524('0x56')]['ids'],_[_0x3524('0xb2')](_0x881a00['body'],[_0x3524('0x69'),'id'])||{})[_0x3524('0x8e')](function(_0x316744){for(var _0x2c0ba3=0x0;_0x2c0ba3<_0x881a00['body']['ids']['length'];_0x2c0ba3+=0x1){socket[_0x3524('0xb3')](_0x3524('0xb4'),{'UserId':Number(_0x881a00[_0x3524('0x56')][_0x3524('0x69')][_0x2c0ba3]),'OpenchannelAccountId':Number(_0x881a00[_0x3524('0x52')]['id'])});}return _0x316744;});}})[_0x3524('0x1d')](respondWithResult(_0x3208a5,null))[_0x3524('0x26')](handleError(_0x3208a5,null));};exports[_0x3524('0xb5')]=function(_0xdfdb9d,_0x587930,_0x415262){return db[_0x3524('0x39')][_0x3524('0x5e')]({'where':{'id':_0xdfdb9d[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x587930,null))[_0x3524('0x1d')](function(_0x27e16a){if(_0x27e16a){return _0x27e16a[_0x3524('0xb5')](_0xdfdb9d[_0x3524('0x3e')][_0x3524('0x69')])['then'](function(){if(_[_0x3524('0xb6')](_0xdfdb9d['query'][_0x3524('0x69')])){for(var _0x3f4816=0x0;_0x3f4816<_0xdfdb9d[_0x3524('0x3e')]['ids']['length'];_0x3f4816+=0x1){socket[_0x3524('0xb3')](_0x3524('0xb7'),{'UserId':Number(_0xdfdb9d[_0x3524('0x3e')][_0x3524('0x69')][_0x3f4816]),'OpenchannelAccountId':Number(_0xdfdb9d['params']['id'])});}}else{socket['emit'](_0x3524('0xb7'),{'UserId':Number(_0xdfdb9d[_0x3524('0x3e')]['ids']),'OpenchannelAccountId':Number(_0xdfdb9d[_0x3524('0x52')]['id'])});}});}})[_0x3524('0x1d')](respondWithStatusCode(_0x587930,null))['catch'](handleError(_0x587930,null));};exports[_0x3524('0xb8')]=function(_0x5242e0,_0x3d7416,_0x4f8840){var _0x1d3a34={};var _0xf5bb47={};var _0x3eff82;var _0x4d3e9a;return db[_0x3524('0x39')]['findOne']({'where':{'id':_0x5242e0[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x3d7416,null))['then'](function(_0x3759d2){if(_0x3759d2){_0x3eff82=_0x3759d2;_0xf5bb47[_0x3524('0x3d')]=_['keys'](db[_0x3524('0x98')][_0x3524('0x54')]);_0xf5bb47['query']=_[_0x3524('0x53')](_0x5242e0[_0x3524('0x3e')]);_0xf5bb47[_0x3524('0x3f')]=_[_0x3524('0x40')](_0xf5bb47['model'],_0xf5bb47[_0x3524('0x3e')]);_0x1d3a34['attributes']=_[_0x3524('0x40')](_0xf5bb47[_0x3524('0x3d')],qs['fields'](_0x5242e0[_0x3524('0x3e')][_0x3524('0x41')]));_0x1d3a34[_0x3524('0x42')]=_0x1d3a34['attributes'][_0x3524('0x43')]?_0x1d3a34[_0x3524('0x42')]:_0xf5bb47[_0x3524('0x3d')];_0x1d3a34[_0x3524('0x45')]=qs['sort'](_0x5242e0['query']['sort']);_0x1d3a34['where']=qs[_0x3524('0x3f')](_[_0x3524('0x48')](_0x5242e0[_0x3524('0x3e')],_0xf5bb47[_0x3524('0x3f')]));if(_0x5242e0[_0x3524('0x3e')][_0x3524('0x49')]){_0x1d3a34['where']=_[_0x3524('0x4a')](_0x1d3a34[_0x3524('0x47')],{'$or':_[_0x3524('0x38')](_0x1d3a34[_0x3524('0x42')],function(_0x52a9d7){var _0x344d12={};_0x344d12[_0x52a9d7]={'$like':'%'+_0x5242e0[_0x3524('0x3e')]['filter']+'%'};return _0x344d12;})});}_0x1d3a34=_[_0x3524('0x4a')]({},_0x1d3a34,_0x5242e0[_0x3524('0x4c')]);return _0x3eff82[_0x3524('0xb8')](_0x1d3a34);}})['then'](function(_0x12b3a6){if(_0x12b3a6){_0x4d3e9a=_0x12b3a6[_0x3524('0x43')];if(!_0x5242e0[_0x3524('0x3e')][_0x3524('0x44')](_0x3524('0x66'))){_0x1d3a34[_0x3524('0x2b')]=qs[_0x3524('0x2b')](_0x5242e0[_0x3524('0x3e')][_0x3524('0x2b')]);_0x1d3a34[_0x3524('0x2a')]=qs[_0x3524('0x2a')](_0x5242e0[_0x3524('0x3e')]['offset']);}return _0x3eff82[_0x3524('0xb8')](_0x1d3a34);}})[_0x3524('0x1d')](function(_0x589782){if(_0x589782){return _0x589782?{'count':_0x4d3e9a,'rows':_0x589782}:null;}})[_0x3524('0x1d')](respondWithResult(_0x3d7416,null))[_0x3524('0x26')](handleError(_0x3d7416,null));};exports['send']=function(_0x1edb36,_0x6584e7,_0x7b2d02){var _0x511101,_0x64d91,_0x3f1704;if(_['isNil'](_0x1edb36[_0x3524('0x56')][_0x3524('0x56')])||_0x1edb36[_0x3524('0x56')][_0x3524('0x56')]===''){throw new db[(_0x3524('0x76'))][(_0x3524('0x70'))](_0x3524('0x78'));}if(_[_0x3524('0x75')](_0x1edb36[_0x3524('0x56')]['to'])){}_0x511101=_0x1edb36[_0x3524('0x56')]['to'];return db[_0x3524('0x39')][_0x3524('0x65')]({'where':{'id':_0x1edb36[_0x3524('0x52')]['id']}})[_0x3524('0x1d')](handleEntityNotFound(_0x6584e7,null))[_0x3524('0x1d')](function(_0x14a454){if(_0x14a454){return db[_0x3524('0x39')][_0x3524('0x5e')]({'where':{'id':_0x14a454['id']},'include':[{'model':db[_0x3524('0x7e')],'as':'List','include':[{'model':db[_0x3524('0x6f')],'as':'Contacts','where':{[_0x14a454[_0x3524('0x79')]]:_0x511101},'limit':0x1,'order':[[_0x3524('0x73'),'DESC']]}]}]})['then'](handleEntityNotFound(_0x6584e7,null))['then'](function(_0x3eaacb){if(_0x3eaacb&&_0x3eaacb[_0x3524('0x7f')]){_0x64d91=_0x3eaacb[_0x3524('0x57')]({'plain':!![]});if(_0x64d91[_0x3524('0x7f')]&&_0x64d91[_0x3524('0x7f')]['Contacts'][_0x3524('0x43')]){return _0x64d91['List'][_0x3524('0x80')][0x0];}return db['CmContact'][_0x3524('0x55')](_[_0x3524('0xb9')](_0x1edb36[_0x3524('0x56')],{'firstName':_0x511101,[_0x3eaacb[_0x3524('0x79')]]:_0x511101,'phone':_0x511101,'ListId':_0x64d91[_0x3524('0x74')]}));}})[_0x3524('0x1d')](handleEntityNotFound(_0x6584e7,null))[_0x3524('0x1d')](function(_0x29d848){if(_0x29d848){_0x3f1704=_0x29d848;return db[_0x3524('0x8c')][_0x3524('0x5e')]({'where':{'ContactId':_0x3f1704['id'],'closed':![],'OpenchannelAccountId':_0x64d91['id']}})[_0x3524('0x1d')](function(_0x41834e){if(_0x41834e){return[_0x41834e,![]];}return db[_0x3524('0x8c')][_0x3524('0x55')]({'UserId':_0x1edb36[_0x3524('0xba')]['id'],'ContactId':_0x3f1704['id'],'OpenchannelAccountId':_0x64d91['id'],'lastMsgDirection':'out','firstMsgDirection':_0x3524('0xbb'),'Messages':[_['merge'](_0x1edb36[_0x3524('0x56')],{'read':![],'body':_0x1edb36['body']['body'],'OpenchannelAccountId':_0x64d91['id'],'UserId':_0x1edb36[_0x3524('0xba')]['id'],'ContactId':_0x3f1704['id']})]},{'include':[{'model':db['OpenchannelMessage'],'as':'Messages'}]})[_0x3524('0x1d')](function(_0x167211){return[_0x167211,!![]];});});}})[_0x3524('0x8e')](function(_0x21213c,_0x67c270){if(_0x67c270){return _0x21213c;}return db['OpenchannelMessage'][_0x3524('0x55')](_[_0x3524('0x4a')](_0x1edb36[_0x3524('0x56')],{'read':![],'body':_0x1edb36[_0x3524('0x56')][_0x3524('0x56')],'OpenchannelAccountId':_0x64d91['id'],'OpenchannelInteractionId':_0x21213c['id'],'UserId':_0x1edb36['user']['id'],'ContactId':_0x3f1704['id']}))[_0x3524('0x1d')](function(_0x2af44f){_0x21213c[_0x3524('0xbc')][_0x3524('0xbd')]=[];_0x21213c['dataValues'][_0x3524('0xbd')][_0x3524('0x94')](_0x2af44f['dataValues']);return _0x21213c;});});}})[_0x3524('0x1d')](respondWithResult(_0x6584e7,null))['catch'](handleError(_0x6584e7,null));};
\ No newline at end of file