Built motion from commit (unavailable).|2.5.18
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index adf931d..0fb2848 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xeec6=['find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','get','UserProfileSection','userProfileId','autoAssociation','describe','addDisposition','OpenchannelAccountId','Disposition','findOne','order','removeDispositions','ids','addAnswer','CannedAnswer','removeAnswers','notify','CmContact','Sequelize','ValidationError','difference','createdAt','updatedAt','CompanyId','isNil','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','CmList','Contacts','DESC','OpenchannelApplication','Applications','List','account','applications','orderBy','priority','asc','from','ListId','firstName','threadId','externalUrl','OpenchannelInteraction','ContactId','spread','contact','messageId','interaction','created','autoclose','close','unmanaged','*,*,*,*','OpenchannelMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','addApplications','transaction','bulkCreate','findAndCountAll','getApplications','getInteractions','Contact','Owner','fullname','internal','Tags','tag','addAgents','omit','emit','userOpenchannelAccount:save','isArray','userOpenchannelAccount:remove','getAgents','Messages','dataValues','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','localhost','./openchannelAccount.socket','register','jayson/promise','client','http','then','info','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','OpenchannelAccount,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','count','offset','limit','Content-Range','apply','update','destroy','OpenchannelAccounts','UserProfileResource','stack','name','send','Pause','mandatoryDispositionPause','OpenchannelAccount','rawAttributes','type','key','model','map','keys','intersection','query','attributes','fields','hasOwnProperty','nolimit','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','params','length'];(function(_0x160cc9,_0xe6e4c9){var _0x5370f1=function(_0x4f9ccd){while(--_0x4f9ccd){_0x160cc9['push'](_0x160cc9['shift']());}};_0x5370f1(++_0xe6e4c9);}(_0xeec6,0x1c2));var _0x6eec=function(_0x3c5e54,_0x2b991b){_0x3c5e54=_0x3c5e54-0x0;var _0x3ae1f3=_0xeec6[_0x3c5e54];return _0x3ae1f3;};'use strict';var pdf=require(_0x6eec('0x0'));var emlformat=require(_0x6eec('0x1'));var rimraf=require(_0x6eec('0x2'));var zipdir=require(_0x6eec('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x6eec('0x4'));var moment=require(_0x6eec('0x5'));var BPromise=require(_0x6eec('0x6'));var Mustache=require(_0x6eec('0x7'));var util=require(_0x6eec('0x8'));var path=require(_0x6eec('0x9'));var sox=require('sox');var csv=require(_0x6eec('0xa'));var ejs=require(_0x6eec('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x6eec('0xc'));var crypto=require(_0x6eec('0xd'));var jsforce=require(_0x6eec('0xe'));var deskjs=require(_0x6eec('0xf'));var toCsv=require('to-csv');var querystring=require(_0x6eec('0x10'));var Papa=require(_0x6eec('0x11'));var Redis=require(_0x6eec('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6eec('0x13'));var logger=require(_0x6eec('0x14'))('api');var utils=require('../../config/utils');var config=require(_0x6eec('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x6eec('0x16'))['db'];config[_0x6eec('0x17')]=_[_0x6eec('0x18')](config[_0x6eec('0x17')],{'host':_0x6eec('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6eec('0x17')]));require(_0x6eec('0x1a'))[_0x6eec('0x1b')](socket);var jayson=require(_0x6eec('0x1c'));var client=jayson[_0x6eec('0x1d')][_0x6eec('0x1e')]({'port':0x232c});var client9002=jayson[_0x6eec('0x1d')][_0x6eec('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x34a7fc,_0x2ac797,_0x5e2a9b,_0x3c0c1b){return new BPromise(function(_0x5f1f33,_0x38c9a4){var _0x45aa3f=_0x3c0c1b||client;return _0x45aa3f['request'](_0x34a7fc,_0x5e2a9b)[_0x6eec('0x1f')](function(_0x80736b){logger[_0x6eec('0x20')]('OpenchannelAccount,\x20%s,\x20%s',_0x2ac797,_0x6eec('0x21'));logger[_0x6eec('0x22')](_0x6eec('0x23'),_0x2ac797,_0x6eec('0x21'),JSON[_0x6eec('0x24')](_0x80736b));if(_0x80736b[_0x6eec('0x25')]){if(_0x80736b['error'][_0x6eec('0x26')]===0x1f4){logger[_0x6eec('0x25')](_0x6eec('0x27'),_0x2ac797,_0x80736b[_0x6eec('0x25')][_0x6eec('0x28')]);return _0x38c9a4(_0x80736b[_0x6eec('0x25')]['message']);}logger[_0x6eec('0x25')](_0x6eec('0x27'),_0x2ac797,_0x80736b[_0x6eec('0x25')][_0x6eec('0x28')]);return _0x5f1f33(_0x80736b[_0x6eec('0x25')][_0x6eec('0x28')]);}else{logger['info'](_0x6eec('0x27'),_0x2ac797,_0x6eec('0x21'));_0x5f1f33(_0x80736b[_0x6eec('0x29')][_0x6eec('0x28')]);}})[_0x6eec('0x2a')](function(_0x1f386c){logger[_0x6eec('0x25')](_0x6eec('0x27'),_0x2ac797,_0x1f386c);_0x38c9a4(_0x1f386c);});});}function respondWithStatusCode(_0x316317,_0x58f95c){_0x58f95c=_0x58f95c||0xcc;return function(_0x1d750c){if(_0x1d750c){return _0x316317[_0x6eec('0x2b')](_0x58f95c);}return _0x316317[_0x6eec('0x2c')](_0x58f95c)[_0x6eec('0x2d')]();};}function respondWithResult(_0x4f507e,_0x23432d){_0x23432d=_0x23432d||0xc8;return function(_0x3b9b9f){if(_0x3b9b9f){return _0x4f507e['status'](_0x23432d)['json'](_0x3b9b9f);}};}function respondWithFilteredResult(_0x3240c3,_0x47ed95){return function(_0x20a130){if(_0x20a130){var _0xede270=_0x20a130[_0x6eec('0x2e')],_0x3bbdf8=_0x47ed95[_0x6eec('0x2f')],_0x34bdea=_0x47ed95[_0x6eec('0x2f')]+_0x47ed95[_0x6eec('0x30')],_0x15e936;if(_0x34bdea>=_0xede270){_0x34bdea=_0xede270;_0x15e936=0xc8;}else{_0x15e936=0xce;}_0x3240c3[_0x6eec('0x2c')](_0x15e936);return _0x3240c3['set'](_0x6eec('0x31'),_0x3bbdf8+'-'+_0x34bdea+'/'+_0xede270)['json'](_0x20a130);}return null;};}function patchUpdates(_0x26f838){return function(_0x125bfc){try{jsonpatch[_0x6eec('0x32')](_0x125bfc,_0x26f838,!![]);}catch(_0x487de8){return BPromise['reject'](_0x487de8);}return _0x125bfc['save']();};}function saveUpdates(_0x183ce3,_0x26b0da){return function(_0x20f850){if(_0x20f850){return _0x20f850[_0x6eec('0x33')](_0x183ce3)[_0x6eec('0x1f')](function(_0x23547d){return _0x23547d;});}return null;};}function removeEntity(_0x22e0cb,_0x167c8d){return function(_0x2bc106){if(_0x2bc106){return _0x2bc106[_0x6eec('0x34')]()[_0x6eec('0x1f')](function(){var _0x4382df=_0x2bc106['get']({'plain':!![]});var _0xd77dd3=_0x6eec('0x35');return db[_0x6eec('0x36')]['destroy']({'where':{'type':_0xd77dd3,'resourceId':_0x4382df['id']}})[_0x6eec('0x1f')](function(){return _0x2bc106;});})[_0x6eec('0x1f')](function(){_0x22e0cb[_0x6eec('0x2c')](0xcc)[_0x6eec('0x2d')]();});}};}function handleEntityNotFound(_0x34d6ba,_0x34d3b1){return function(_0x4a7699){if(!_0x4a7699){_0x34d6ba[_0x6eec('0x2b')](0x194);}return _0x4a7699;};}function handleError(_0x1f10ff,_0x2f18e9){_0x2f18e9=_0x2f18e9||0x1f4;return function(_0x5128ac){logger['error'](_0x5128ac[_0x6eec('0x37')]);if(_0x5128ac[_0x6eec('0x38')]){delete _0x5128ac[_0x6eec('0x38')];}_0x1f10ff[_0x6eec('0x2c')](_0x2f18e9)[_0x6eec('0x39')](_0x5128ac);};}exports['index']=function(_0x223dfa,_0x2c3b14){var _0x44118c={'include':[{'model':db[_0x6eec('0x3a')],'as':_0x6eec('0x3b')}]},_0x2bf388={},_0x15918c={'count':0x0,'rows':[]};var _0x1deed2=_['map'](db[_0x6eec('0x3c')][_0x6eec('0x3d')],function(_0x4d30c9){return{'name':_0x4d30c9['fieldName'],'type':_0x4d30c9[_0x6eec('0x3e')][_0x6eec('0x3f')]};});_0x2bf388[_0x6eec('0x40')]=_[_0x6eec('0x41')](_0x1deed2,'name');_0x2bf388['query']=_[_0x6eec('0x42')](_0x223dfa['query']);_0x2bf388['filters']=_[_0x6eec('0x43')](_0x2bf388[_0x6eec('0x40')],_0x2bf388[_0x6eec('0x44')]);_0x44118c[_0x6eec('0x45')]=_[_0x6eec('0x43')](_0x2bf388['model'],qs[_0x6eec('0x46')](_0x223dfa[_0x6eec('0x44')]['fields']));_0x44118c[_0x6eec('0x45')]=_0x44118c[_0x6eec('0x45')]['length']?_0x44118c[_0x6eec('0x45')]:_0x2bf388[_0x6eec('0x40')];if(!_0x223dfa['query'][_0x6eec('0x47')](_0x6eec('0x48'))){_0x44118c[_0x6eec('0x30')]=qs[_0x6eec('0x30')](_0x223dfa['query'][_0x6eec('0x30')]);_0x44118c[_0x6eec('0x2f')]=qs[_0x6eec('0x2f')](_0x223dfa[_0x6eec('0x44')][_0x6eec('0x2f')]);}_0x44118c['order']=qs['sort'](_0x223dfa[_0x6eec('0x44')][_0x6eec('0x49')]);_0x44118c[_0x6eec('0x4a')]=qs[_0x6eec('0x4b')](_[_0x6eec('0x4c')](_0x223dfa['query'],_0x2bf388[_0x6eec('0x4b')]),_0x1deed2);if(_0x223dfa['query'][_0x6eec('0x4d')]){_0x44118c[_0x6eec('0x4a')]=_[_0x6eec('0x4e')](_0x44118c['where'],{'$or':_[_0x6eec('0x41')](_0x1deed2,function(_0x35a4a5){if(_0x35a4a5[_0x6eec('0x3e')]!==_0x6eec('0x4f')){var _0x2417e6={};_0x2417e6[_0x35a4a5['name']]={'$like':'%'+_0x223dfa[_0x6eec('0x44')]['filter']+'%'};return _0x2417e6;}})});}_0x44118c=_['merge']({},_0x44118c,_0x223dfa[_0x6eec('0x50')]);var _0x535d96={'where':_0x44118c[_0x6eec('0x4a')]};return db[_0x6eec('0x3c')][_0x6eec('0x2e')](_0x535d96)['then'](function(_0x4b4223){_0x15918c[_0x6eec('0x2e')]=_0x4b4223;if(_0x223dfa[_0x6eec('0x44')][_0x6eec('0x51')]){_0x44118c[_0x6eec('0x52')]=[{'all':!![]}];}return db[_0x6eec('0x3c')][_0x6eec('0x53')](_0x44118c);})[_0x6eec('0x1f')](function(_0x442bca){_0x15918c[_0x6eec('0x54')]=_0x442bca;return _0x15918c;})[_0x6eec('0x1f')](respondWithFilteredResult(_0x2c3b14,_0x44118c))['catch'](handleError(_0x2c3b14,null));};exports['show']=function(_0x1a8cf6,_0x2270ce){var _0x38e836={'raw':![],'where':{'id':_0x1a8cf6[_0x6eec('0x55')]['id']},'include':[{'model':db[_0x6eec('0x3a')],'as':_0x6eec('0x3b')}]},_0x577fb6={};_0x577fb6[_0x6eec('0x40')]=_[_0x6eec('0x42')](db[_0x6eec('0x3c')][_0x6eec('0x3d')]);_0x577fb6[_0x6eec('0x44')]=_['keys'](_0x1a8cf6[_0x6eec('0x44')]);_0x577fb6[_0x6eec('0x4b')]=_[_0x6eec('0x43')](_0x577fb6[_0x6eec('0x40')],_0x577fb6['query']);_0x38e836['attributes']=_['intersection'](_0x577fb6[_0x6eec('0x40')],qs[_0x6eec('0x46')](_0x1a8cf6[_0x6eec('0x44')][_0x6eec('0x46')]));_0x38e836['attributes']=_0x38e836['attributes'][_0x6eec('0x56')]?_0x38e836[_0x6eec('0x45')]:_0x577fb6[_0x6eec('0x40')];if(_0x1a8cf6['query'][_0x6eec('0x51')]){_0x38e836[_0x6eec('0x52')]=[{'all':!![]}];}_0x38e836=_[_0x6eec('0x4e')]({},_0x38e836,_0x1a8cf6[_0x6eec('0x50')]);return db[_0x6eec('0x3c')][_0x6eec('0x57')](_0x38e836)[_0x6eec('0x1f')](handleEntityNotFound(_0x2270ce,null))[_0x6eec('0x1f')](respondWithResult(_0x2270ce,null))[_0x6eec('0x2a')](handleError(_0x2270ce,null));};exports['create']=function(_0x22cf6c,_0x5e51c9){return db[_0x6eec('0x3c')][_0x6eec('0x58')](_0x22cf6c[_0x6eec('0x59')],{})[_0x6eec('0x1f')](function(_0x248d76){var _0x360176=_0x22cf6c[_0x6eec('0x5a')]['get']({'plain':!![]});if(!_0x360176)throw new Error(_0x6eec('0x5b'));if(_0x360176['role']===_0x6eec('0x5a')){var _0x5c905f=_0x248d76[_0x6eec('0x5c')]({'plain':!![]});var _0xd7e19b=_0x6eec('0x35');return db[_0x6eec('0x5d')][_0x6eec('0x57')]({'where':{'name':_0xd7e19b,'userProfileId':_0x360176[_0x6eec('0x5e')]},'raw':!![]})[_0x6eec('0x1f')](function(_0x2982a8){if(_0x2982a8&&_0x2982a8[_0x6eec('0x5f')]===0x0){return db[_0x6eec('0x36')]['create']({'name':_0x5c905f['name'],'resourceId':_0x5c905f['id'],'type':_0x2982a8[_0x6eec('0x38')],'sectionId':_0x2982a8['id']},{})[_0x6eec('0x1f')](function(){return _0x248d76;});}else{return _0x248d76;}})[_0x6eec('0x2a')](function(_0x2c0644){logger[_0x6eec('0x25')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2c0644);throw _0x2c0644;});}return _0x248d76;})[_0x6eec('0x1f')](respondWithResult(_0x5e51c9,0xc9))[_0x6eec('0x2a')](handleError(_0x5e51c9,null));};exports['update']=function(_0x5dc4d1,_0x5dc8b3){if(_0x5dc4d1[_0x6eec('0x59')]['id']){delete _0x5dc4d1[_0x6eec('0x59')]['id'];}return db['OpenchannelAccount'][_0x6eec('0x57')]({'where':{'id':_0x5dc4d1[_0x6eec('0x55')]['id']},'include':[{'model':db['Pause'],'as':_0x6eec('0x3b')}]})[_0x6eec('0x1f')](handleEntityNotFound(_0x5dc8b3,null))[_0x6eec('0x1f')](saveUpdates(_0x5dc4d1[_0x6eec('0x59')],null))['then'](respondWithResult(_0x5dc8b3,null))['catch'](handleError(_0x5dc8b3,null));};exports[_0x6eec('0x34')]=function(_0x1230fc,_0x460488){return db[_0x6eec('0x3c')][_0x6eec('0x57')]({'where':{'id':_0x1230fc[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x460488,null))[_0x6eec('0x1f')](removeEntity(_0x460488,null))[_0x6eec('0x2a')](handleError(_0x460488,null));};exports[_0x6eec('0x60')]=function(_0x42f435,_0x9819f6){return db[_0x6eec('0x3c')][_0x6eec('0x60')]()[_0x6eec('0x1f')](respondWithResult(_0x9819f6,null))[_0x6eec('0x2a')](handleError(_0x9819f6,null));};exports[_0x6eec('0x61')]=function(_0x4dac02,_0x2ef374,_0x2236f7){if(_0x4dac02['body']['id']){delete _0x4dac02[_0x6eec('0x59')]['id'];}return db[_0x6eec('0x3c')]['find']({'where':{'id':_0x4dac02[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x2ef374,null))[_0x6eec('0x1f')](function(_0x394aaf){if(_0x394aaf){_0x4dac02['body'][_0x6eec('0x62')]=_0x394aaf['id'];return db[_0x6eec('0x63')][_0x6eec('0x58')](_0x4dac02[_0x6eec('0x59')]);}})[_0x6eec('0x1f')](respondWithResult(_0x2ef374,null))[_0x6eec('0x2a')](handleError(_0x2ef374,null));};exports['getDispositions']=function(_0x1ed47e,_0x4abeae,_0x471d55){var _0x19927d={'raw':![],'where':{}};var _0x261021={};var _0x12f429={'count':0x0,'rows':[]};return db[_0x6eec('0x3c')][_0x6eec('0x64')]({'where':{'id':_0x1ed47e[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x4abeae,null))[_0x6eec('0x1f')](function(_0x5a7aa4){if(_0x5a7aa4){_0x261021[_0x6eec('0x40')]=_[_0x6eec('0x42')](db[_0x6eec('0x63')]['rawAttributes']);_0x261021[_0x6eec('0x44')]=_[_0x6eec('0x42')](_0x1ed47e['query']);_0x261021[_0x6eec('0x4b')]=_[_0x6eec('0x43')](_0x261021[_0x6eec('0x40')],_0x261021[_0x6eec('0x44')]);_0x19927d[_0x6eec('0x45')]=_['intersection'](_0x261021[_0x6eec('0x40')],qs[_0x6eec('0x46')](_0x1ed47e[_0x6eec('0x44')][_0x6eec('0x46')]));_0x19927d[_0x6eec('0x45')]=_0x19927d['attributes'][_0x6eec('0x56')]?_0x19927d[_0x6eec('0x45')]:_0x261021[_0x6eec('0x40')];if(!_0x1ed47e[_0x6eec('0x44')][_0x6eec('0x47')](_0x6eec('0x48'))){_0x19927d[_0x6eec('0x30')]=qs[_0x6eec('0x30')](_0x1ed47e['query'][_0x6eec('0x30')]);_0x19927d['offset']=qs[_0x6eec('0x2f')](_0x1ed47e[_0x6eec('0x44')][_0x6eec('0x2f')]);}_0x19927d[_0x6eec('0x65')]=qs['sort'](_0x1ed47e[_0x6eec('0x44')]['sort']);_0x19927d[_0x6eec('0x4a')]=qs[_0x6eec('0x4b')](_[_0x6eec('0x4c')](_0x1ed47e[_0x6eec('0x44')],_0x261021['filters']));_0x19927d['where']['OpenchannelAccountId']=_0x5a7aa4['id'];if(_0x1ed47e[_0x6eec('0x44')][_0x6eec('0x4d')]){_0x19927d[_0x6eec('0x4a')]=_[_0x6eec('0x4e')](_0x19927d['where'],{'$or':_[_0x6eec('0x41')](_0x19927d['attributes'],function(_0x297109){var _0x152250={};_0x152250[_0x297109]={'$like':'%'+_0x1ed47e['query'][_0x6eec('0x4d')]+'%'};return _0x152250;})});}_0x19927d=_[_0x6eec('0x4e')]({},_0x19927d,_0x1ed47e[_0x6eec('0x50')]);return db[_0x6eec('0x63')][_0x6eec('0x2e')]({'where':_0x19927d[_0x6eec('0x4a')]})['then'](function(_0x1d2aaa){_0x12f429['count']=_0x1d2aaa;if(_0x1ed47e[_0x6eec('0x44')][_0x6eec('0x51')]){_0x19927d['include']=[{'all':!![]}];}return db[_0x6eec('0x63')]['findAll'](_0x19927d);})[_0x6eec('0x1f')](function(_0x1d1683){_0x12f429[_0x6eec('0x54')]=_0x1d1683;return _0x12f429;});}})[_0x6eec('0x1f')](respondWithFilteredResult(_0x4abeae,_0x19927d))['catch'](handleError(_0x4abeae,null));};exports[_0x6eec('0x66')]=function(_0x566ccf,_0x3f04a0,_0x2c0a85){return db['OpenchannelAccount'][_0x6eec('0x57')]({'where':{'id':_0x566ccf[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x3f04a0,null))[_0x6eec('0x1f')](function(_0x15c9a3){if(_0x15c9a3){return _0x15c9a3['removeDispositions'](_0x566ccf[_0x6eec('0x44')][_0x6eec('0x67')]);}})[_0x6eec('0x1f')](respondWithStatusCode(_0x3f04a0,null))[_0x6eec('0x2a')](handleError(_0x3f04a0,null));};exports[_0x6eec('0x68')]=function(_0x471e01,_0x485d04,_0x4a3af3){if(_0x471e01[_0x6eec('0x59')]['id']){delete _0x471e01[_0x6eec('0x59')]['id'];}return db['OpenchannelAccount']['find']({'where':{'id':_0x471e01[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x485d04,null))['then'](function(_0x2c7853){if(_0x2c7853){_0x471e01[_0x6eec('0x59')][_0x6eec('0x62')]=_0x2c7853['id'];return db['CannedAnswer'][_0x6eec('0x58')](_0x471e01['body']);}})[_0x6eec('0x1f')](respondWithResult(_0x485d04,null))[_0x6eec('0x2a')](handleError(_0x485d04,null));};exports['getAnswers']=function(_0x3a6c48,_0x395bda,_0x4215f0){var _0x4a7a37={'raw':![],'where':{}};var _0xf4f91={};var _0xc4e3bc={'count':0x0,'rows':[]};return db[_0x6eec('0x3c')][_0x6eec('0x64')]({'where':{'id':_0x3a6c48[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x395bda,null))['then'](function(_0x4be9a7){if(_0x4be9a7){_0xf4f91[_0x6eec('0x40')]=_[_0x6eec('0x42')](db[_0x6eec('0x69')][_0x6eec('0x3d')]);_0xf4f91[_0x6eec('0x44')]=_[_0x6eec('0x42')](_0x3a6c48[_0x6eec('0x44')]);_0xf4f91[_0x6eec('0x4b')]=_[_0x6eec('0x43')](_0xf4f91[_0x6eec('0x40')],_0xf4f91[_0x6eec('0x44')]);_0x4a7a37['attributes']=_[_0x6eec('0x43')](_0xf4f91[_0x6eec('0x40')],qs[_0x6eec('0x46')](_0x3a6c48[_0x6eec('0x44')][_0x6eec('0x46')]));_0x4a7a37[_0x6eec('0x45')]=_0x4a7a37[_0x6eec('0x45')][_0x6eec('0x56')]?_0x4a7a37[_0x6eec('0x45')]:_0xf4f91[_0x6eec('0x40')];if(!_0x3a6c48[_0x6eec('0x44')][_0x6eec('0x47')](_0x6eec('0x48'))){_0x4a7a37[_0x6eec('0x30')]=qs[_0x6eec('0x30')](_0x3a6c48['query'][_0x6eec('0x30')]);_0x4a7a37['offset']=qs[_0x6eec('0x2f')](_0x3a6c48[_0x6eec('0x44')][_0x6eec('0x2f')]);}_0x4a7a37[_0x6eec('0x65')]=qs['sort'](_0x3a6c48[_0x6eec('0x44')]['sort']);_0x4a7a37[_0x6eec('0x4a')]=qs[_0x6eec('0x4b')](_[_0x6eec('0x4c')](_0x3a6c48[_0x6eec('0x44')],_0xf4f91[_0x6eec('0x4b')]));_0x4a7a37[_0x6eec('0x4a')]['OpenchannelAccountId']=_0x4be9a7['id'];if(_0x3a6c48[_0x6eec('0x44')][_0x6eec('0x4d')]){_0x4a7a37[_0x6eec('0x4a')]=_[_0x6eec('0x4e')](_0x4a7a37['where'],{'$or':_['map'](_0x4a7a37[_0x6eec('0x45')],function(_0x2eb5ed){var _0x52771a={};_0x52771a[_0x2eb5ed]={'$like':'%'+_0x3a6c48['query'][_0x6eec('0x4d')]+'%'};return _0x52771a;})});}_0x4a7a37=_[_0x6eec('0x4e')]({},_0x4a7a37,_0x3a6c48['options']);return db[_0x6eec('0x69')][_0x6eec('0x2e')]({'where':_0x4a7a37['where']})[_0x6eec('0x1f')](function(_0x3cc039){_0xc4e3bc[_0x6eec('0x2e')]=_0x3cc039;if(_0x3a6c48['query']['includeAll']){_0x4a7a37['include']=[{'all':!![]}];}return db[_0x6eec('0x69')]['findAll'](_0x4a7a37);})['then'](function(_0x41d777){_0xc4e3bc['rows']=_0x41d777;return _0xc4e3bc;});}})[_0x6eec('0x1f')](respondWithFilteredResult(_0x395bda,_0x4a7a37))[_0x6eec('0x2a')](handleError(_0x395bda,null));};exports[_0x6eec('0x6a')]=function(_0x5e0f6a,_0x31248a,_0xae96c9){return db['OpenchannelAccount']['find']({'where':{'id':_0x5e0f6a['params']['id']}})['then'](handleEntityNotFound(_0x31248a,null))['then'](function(_0x188346){if(_0x188346){return _0x188346[_0x6eec('0x6a')](_0x5e0f6a[_0x6eec('0x44')][_0x6eec('0x67')]);}})['then'](respondWithStatusCode(_0x31248a,null))['catch'](handleError(_0x31248a,null));};exports[_0x6eec('0x6b')]=function(_0x5bad60,_0x12c845,_0x5dcd38){var _0x1eb3c6={'body':_0x5bad60[_0x6eec('0x59')],'channel':'openchannel'};var _0x5b47d2=[];var _0x1fada6=[];var _0xd4919e={};var _0x4e3e03=![];return db[_0x6eec('0x6c')][_0x6eec('0x60')]()[_0x6eec('0x1f')](function(_0x1403b4){if(!_0x1403b4){throw new db[(_0x6eec('0x6d'))][(_0x6eec('0x6e'))]('no\x20available\x20attributes');}_0x5b47d2=_[_0x6eec('0x6f')](_[_0x6eec('0x42')](_0x1403b4),[_0x6eec('0x70'),_0x6eec('0x71')]);_0x1fada6=_['difference'](_[_0x6eec('0x42')](_0x1403b4),[_0x6eec('0x70'),_0x6eec('0x71'),_0x6eec('0x72'),'ListId']);if(_0x5bad60[_0x6eec('0x59')]['id']){delete _0x5bad60[_0x6eec('0x59')]['id'];}if(_[_0x6eec('0x73')](_0x5bad60[_0x6eec('0x59')]['from'])){throw new db['Sequelize'][(_0x6eec('0x6e'))]('from\x20is\x20mandatory');}if(_['isNil'](_0x5bad60['body'][_0x6eec('0x59')])||_0x5bad60['body'][_0x6eec('0x59')]===''){throw new db[(_0x6eec('0x6d'))][(_0x6eec('0x6e'))](_0x6eec('0x74'));}if(_[_0x6eec('0x73')](_0x5bad60[_0x6eec('0x59')][_0x6eec('0x75')])){throw new db[(_0x6eec('0x6d'))]['ValidationError'](_0x6eec('0x76')+_0x1fada6);}if(!_[_0x6eec('0x77')](_0x1fada6,_0x5bad60[_0x6eec('0x59')][_0x6eec('0x75')])){throw new db[(_0x6eec('0x6d'))]['ValidationError']('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x1fada6);}_0xd4919e[_0x5bad60['body'][_0x6eec('0x75')]]=_0x5bad60[_0x6eec('0x59')]['from'];})[_0x6eec('0x1f')](function(){return db['OpenchannelAccount'][_0x6eec('0x57')]({'where':{'id':_0x5bad60['params']['id']},'include':[{'model':db[_0x6eec('0x78')],'as':'List','include':[{'model':db['CmContact'],'as':_0x6eec('0x79'),'where':_0xd4919e,'limit':0x1,'order':[[_0x6eec('0x71'),_0x6eec('0x7a')]]}]},{'model':db[_0x6eec('0x7b')],'as':_0x6eec('0x7c')}]});})[_0x6eec('0x1f')](handleEntityNotFound(_0x12c845,null))['then'](function(_0x4dfef5){if(_0x4dfef5&&_0x4dfef5[_0x6eec('0x7d')]){_0x1eb3c6[_0x6eec('0x7e')]=_0x4dfef5;_0x1eb3c6['applications']=_0x4dfef5[_0x6eec('0x7c')];_0x1eb3c6['list']=_0x4dfef5[_0x6eec('0x7d')];_0x1eb3c6[_0x6eec('0x7f')]=_[_0x6eec('0x80')](_0x1eb3c6['applications'],[_0x6eec('0x81')],[_0x6eec('0x82')]);if(_0x1eb3c6[_0x6eec('0x7e')]['Applications']){delete _0x1eb3c6[_0x6eec('0x7e')][_0x6eec('0x7c')];}if(_0x1eb3c6['account'][_0x6eec('0x7d')]&&_0x1eb3c6['account'][_0x6eec('0x7d')]['Contacts'][_0x6eec('0x56')]){return _0x1eb3c6[_0x6eec('0x7e')][_0x6eec('0x7d')][_0x6eec('0x79')][0x0];}var _0x1416cf=_[_0x6eec('0x18')](_0x5bad60[_0x6eec('0x59')],{'firstName':_0x5bad60[_0x6eec('0x59')][_0x6eec('0x83')],'ListId':_0x4dfef5[_0x6eec('0x84')]});_0x1416cf[_0x5bad60[_0x6eec('0x59')][_0x6eec('0x75')]]=_0x5bad60[_0x6eec('0x59')][_0x6eec('0x83')];return db[_0x6eec('0x6c')][_0x6eec('0x58')](_0x1416cf,{'fields':_0x5b47d2,'raw':!![]});}})[_0x6eec('0x1f')](handleEntityNotFound(_0x12c845,null))[_0x6eec('0x1f')](function(_0x29343e){_0x1eb3c6['contact']=_0x29343e;if(_0x29343e){var _0x451a1f={'ContactId':_0x29343e['id'],'OpenchannelAccountId':_0x5bad60[_0x6eec('0x55')]['id'],'from':(_0x29343e[_0x6eec('0x85')]||'')+'\x20'+(_0x29343e['lastName']||'')};var _0x111115={'OpenchannelAccountId':_0x5bad60[_0x6eec('0x55')]['id'],'closed':![]};if(_0x5bad60[_0x6eec('0x59')]['threadId']){_0x111115[_0x6eec('0x86')]=_0x5bad60[_0x6eec('0x59')][_0x6eec('0x86')];return db['OpenchannelInteraction'][_0x6eec('0x57')]({'where':_0x111115})[_0x6eec('0x1f')](function(_0x60d39f){if(_0x60d39f){return[_0x60d39f,![]];}_0x451a1f[_0x6eec('0x86')]=_0x5bad60[_0x6eec('0x59')][_0x6eec('0x86')];_0x451a1f['externalUrl']=_0x5bad60[_0x6eec('0x59')][_0x6eec('0x87')];return db[_0x6eec('0x88')][_0x6eec('0x58')](_0x451a1f)[_0x6eec('0x1f')](function(_0xa19adc){return[_0xa19adc,!![]];});});}else{_0x111115['threadId']=null;}_0x111115[_0x6eec('0x89')]=_0x29343e['id'];return db[_0x6eec('0x88')][_0x6eec('0x57')]({'where':_0x111115})[_0x6eec('0x1f')](function(_0x414320){if(_0x414320){return[_0x414320,![]];}return db['OpenchannelInteraction'][_0x6eec('0x58')](_0x451a1f)[_0x6eec('0x1f')](function(_0x416241){return[_0x416241,!![]];});});}})[_0x6eec('0x8a')](function(_0x8d62d4,_0x551826){if(_0x8d62d4){_0x4e3e03=_0x551826;if(!_0x551826){var _0x2b4e61={'from':(_0x1eb3c6[_0x6eec('0x8b')][_0x6eec('0x85')]||'')+'\x20'+(_0x1eb3c6['contact']['lastName']||'')};if(_0x5bad60[_0x6eec('0x59')][_0x6eec('0x86')]&&_0x5bad60[_0x6eec('0x59')]['messageId']&&_0x5bad60['body']['threadId']!=_0x5bad60[_0x6eec('0x59')][_0x6eec('0x8c')]){_0x2b4e61['threadId']=_0x5bad60['body'][_0x6eec('0x8c')];}return _0x8d62d4['update'](_0x2b4e61);}else{return _0x8d62d4;}}})[_0x6eec('0x1f')](function(_0x447d4d){_0x1eb3c6['interaction']=_0x447d4d[_0x6eec('0x5c')]({'plain':!![]});_0x1eb3c6[_0x6eec('0x8d')][_0x6eec('0x8e')]=_0x4e3e03;if(_0x1eb3c6[_0x6eec('0x8d')][_0x6eec('0x8e')]){if(_0x1eb3c6['account'][_0x6eec('0x8f')]){_0x1eb3c6[_0x6eec('0x7f')]['push']({'id':0x0,'priority':_0x1eb3c6['applications']['length']+0x1,'app':_0x6eec('0x90'),'appdata':_0x6eec('0x91'),'interval':_0x6eec('0x92')});}}return db[_0x6eec('0x93')][_0x6eec('0x58')]({'body':_0x5bad60[_0x6eec('0x59')][_0x6eec('0x59')],'OpenchannelAccountId':_0x5bad60[_0x6eec('0x55')]['id'],'OpenchannelInteractionId':_0x447d4d['id'],'direction':'in','ContactId':_0x1eb3c6[_0x6eec('0x8b')]['id'],'AttachmentId':_0x5bad60['body'][_0x6eec('0x94')]});})['then'](function(_0x21f5be){_0x1eb3c6[_0x6eec('0x28')]=_0x21f5be;if(_0x1eb3c6[_0x6eec('0x8d')][_0x6eec('0x95')]){return db[_0x6eec('0x96')][_0x6eec('0x57')]({'attributes':['id',_0x6eec('0x38')],'where':{'id':_0x1eb3c6[_0x6eec('0x8d')][_0x6eec('0x95')]}})['then'](function(_0xee3d4e){if(_0xee3d4e){_0x1eb3c6['applications'][_0x6eec('0x97')]({'id':0x0,'priority':0x0,'app':_0x6eec('0x98'),'appdata':_0xee3d4e[_0x6eec('0x38')]+','+(_0x1eb3c6[_0x6eec('0x7e')][_0x6eec('0x99')]||0xa),'interval':'*,*,*,*'});_0x1eb3c6[_0x6eec('0x9a')]=![];}return respondWithRpcPromise(_0x6eec('0x9b'),'startRouting',_0x1eb3c6);});}return respondWithRpcPromise(_0x6eec('0x9b'),_0x6eec('0x9c'),_0x1eb3c6);})['then'](function(_0x24bc75){respondWithRpcPromise(_0x6eec('0x9d'),_0x6eec('0x9d'),{'event':_0x6eec('0x6b'),'message':_0x24bc75},client9002);return _0x24bc75;})['then'](respondWithResult(_0x12c845,null))[_0x6eec('0x2a')](handleError(_0x12c845,null));};exports[_0x6eec('0x9e')]=function(_0x5ec371,_0x1ccd02,_0x9c1520){return db[_0x6eec('0x3c')][_0x6eec('0x64')]({'where':{'id':_0x5ec371[_0x6eec('0x55')]['id']}})['then'](handleEntityNotFound(_0x1ccd02,null))[_0x6eec('0x1f')](function(_0x5d3f6b){if(_0x5d3f6b){return db['sequelize'][_0x6eec('0x9f')](function(_0x17a4e4){return db[_0x6eec('0x7b')][_0x6eec('0x34')]({'where':{'OpenchannelAccountId':_0x5ec371[_0x6eec('0x55')]['id']},'transaction':_0x17a4e4})[_0x6eec('0x1f')](function(_0x84c86a){var _0x3d55b2=_[_0x6eec('0x41')](_0x5ec371['body'],function(_0x31cc05){_0x31cc05[_0x6eec('0x62')]=_0x5ec371[_0x6eec('0x55')]['id'];return _0x31cc05;});return db[_0x6eec('0x7b')][_0x6eec('0xa0')](_0x3d55b2,{'transaction':_0x17a4e4});});})['then'](function(){return db[_0x6eec('0x7b')][_0x6eec('0xa1')]({'where':{'OpenchannelAccountId':_0x5ec371[_0x6eec('0x55')]['id']},'order':'priority'});});}})[_0x6eec('0x1f')](respondWithResult(_0x1ccd02,null))[_0x6eec('0x2a')](handleError(_0x1ccd02,null));};exports[_0x6eec('0xa2')]=function(_0x57c596,_0x152680,_0x17868f){var _0x45a029={};var _0x5c37fe={};var _0x2d6411;var _0x19335e;return db['OpenchannelAccount'][_0x6eec('0x64')]({'where':{'id':_0x57c596[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x152680,null))['then'](function(_0x4591f1){if(_0x4591f1){_0x2d6411=_0x4591f1;_0x5c37fe[_0x6eec('0x40')]=_[_0x6eec('0x42')](db[_0x6eec('0x7b')][_0x6eec('0x3d')]);_0x5c37fe['query']=_[_0x6eec('0x42')](_0x57c596[_0x6eec('0x44')]);_0x5c37fe[_0x6eec('0x4b')]=_[_0x6eec('0x43')](_0x5c37fe['model'],_0x5c37fe['query']);_0x45a029[_0x6eec('0x45')]=_[_0x6eec('0x43')](_0x5c37fe['model'],qs[_0x6eec('0x46')](_0x57c596[_0x6eec('0x44')][_0x6eec('0x46')]));_0x45a029[_0x6eec('0x45')]=_0x45a029[_0x6eec('0x45')][_0x6eec('0x56')]?_0x45a029[_0x6eec('0x45')]:_0x5c37fe['model'];_0x45a029['order']=qs[_0x6eec('0x49')](_0x57c596[_0x6eec('0x44')][_0x6eec('0x49')]);_0x45a029[_0x6eec('0x4a')]=qs['filters'](_['pick'](_0x57c596[_0x6eec('0x44')],_0x5c37fe[_0x6eec('0x4b')]));if(_0x57c596[_0x6eec('0x44')][_0x6eec('0x4d')]){_0x45a029[_0x6eec('0x4a')]=_[_0x6eec('0x4e')](_0x45a029[_0x6eec('0x4a')],{'$or':_[_0x6eec('0x41')](_0x45a029[_0x6eec('0x45')],function(_0x411a51){var _0x3f81a1={};_0x3f81a1[_0x411a51]={'$like':'%'+_0x57c596[_0x6eec('0x44')][_0x6eec('0x4d')]+'%'};return _0x3f81a1;})});}_0x45a029=_[_0x6eec('0x4e')]({},_0x45a029,_0x57c596[_0x6eec('0x50')]);return _0x2d6411[_0x6eec('0xa2')](_0x45a029);}})[_0x6eec('0x1f')](function(_0x139fe5){if(_0x139fe5){_0x19335e=_0x139fe5[_0x6eec('0x56')];if(!_0x57c596[_0x6eec('0x44')][_0x6eec('0x47')](_0x6eec('0x48'))){_0x45a029[_0x6eec('0x30')]=qs[_0x6eec('0x30')](_0x57c596['query'][_0x6eec('0x30')]);_0x45a029[_0x6eec('0x2f')]=qs[_0x6eec('0x2f')](_0x57c596[_0x6eec('0x44')][_0x6eec('0x2f')]);}return _0x2d6411[_0x6eec('0xa2')](_0x45a029);}})[_0x6eec('0x1f')](function(_0x5663ef){if(_0x5663ef){return _0x5663ef?{'count':_0x19335e,'rows':_0x5663ef}:null;}})[_0x6eec('0x1f')](respondWithResult(_0x152680,null))['catch'](handleError(_0x152680,null));};exports[_0x6eec('0xa3')]=function(_0x40ef2b,_0x54de03,_0x3f4c88){var _0x50c99d={'raw':![],'where':{}};var _0x41ed3f={};var _0x51a303={'count':0x0,'rows':[]};return db['OpenchannelAccount']['findOne']({'where':{'id':_0x40ef2b[_0x6eec('0x55')]['id']}})['then'](handleEntityNotFound(_0x54de03,null))[_0x6eec('0x1f')](function(_0x13ec21){if(_0x13ec21){_0x41ed3f['model']=_[_0x6eec('0x42')](db[_0x6eec('0x88')]['rawAttributes']);_0x41ed3f[_0x6eec('0x44')]=_[_0x6eec('0x42')](_0x40ef2b[_0x6eec('0x44')]);_0x41ed3f['filters']=_[_0x6eec('0x43')](_0x41ed3f['model'],_0x41ed3f[_0x6eec('0x44')]);_0x50c99d[_0x6eec('0x45')]=_['intersection'](_0x41ed3f['model'],qs[_0x6eec('0x46')](_0x40ef2b['query'][_0x6eec('0x46')]));_0x50c99d[_0x6eec('0x45')]=_0x50c99d[_0x6eec('0x45')][_0x6eec('0x56')]?_0x50c99d['attributes']:_0x41ed3f[_0x6eec('0x40')];if(!_0x40ef2b[_0x6eec('0x44')][_0x6eec('0x47')](_0x6eec('0x48'))){_0x50c99d[_0x6eec('0x30')]=qs[_0x6eec('0x30')](_0x40ef2b[_0x6eec('0x44')][_0x6eec('0x30')]);_0x50c99d[_0x6eec('0x2f')]=qs[_0x6eec('0x2f')](_0x40ef2b[_0x6eec('0x44')]['offset']);}_0x50c99d[_0x6eec('0x65')]=qs['sort'](_0x40ef2b['query'][_0x6eec('0x49')]);_0x50c99d[_0x6eec('0x4a')]=qs[_0x6eec('0x4b')](_['pick'](_0x40ef2b['query'],_0x41ed3f['filters']));_0x50c99d['where']['OpenchannelAccountId']=_0x13ec21['id'];if(_0x40ef2b[_0x6eec('0x44')][_0x6eec('0x4d')]){_0x50c99d[_0x6eec('0x4a')]=_[_0x6eec('0x4e')](_0x50c99d[_0x6eec('0x4a')],{'$or':_[_0x6eec('0x41')](_0x50c99d[_0x6eec('0x45')],function(_0x335d70){var _0x360638={};_0x360638[_0x335d70]={'$like':'%'+_0x40ef2b[_0x6eec('0x44')][_0x6eec('0x4d')]+'%'};return _0x360638;})});}_0x50c99d=_[_0x6eec('0x4e')]({},_0x50c99d,_0x40ef2b[_0x6eec('0x50')]);return db[_0x6eec('0x88')][_0x6eec('0x2e')]({'where':_0x50c99d[_0x6eec('0x4a')]})[_0x6eec('0x1f')](function(_0x3be645){_0x51a303[_0x6eec('0x2e')]=_0x3be645;if(_0x40ef2b[_0x6eec('0x44')]['includeAll']){_0x50c99d[_0x6eec('0x52')]=[{'model':db[_0x6eec('0x6c')],'as':_0x6eec('0xa4'),'required':![]},{'model':db[_0x6eec('0x96')],'as':_0x6eec('0xa5'),'attributes':['name',_0x6eec('0xa6'),_0x6eec('0xa7')],'required':![]},{'model':db['Tag'],'as':_0x6eec('0xa8'),'attributes':['id','name','color'],'where':_0x40ef2b[_0x6eec('0x44')][_0x6eec('0xa9')]?{'id':_0x40ef2b[_0x6eec('0x44')][_0x6eec('0xa9')]}:undefined,'required':_0x40ef2b['query']['tag']?!![]:![]}];}return db[_0x6eec('0x88')][_0x6eec('0x53')](_0x50c99d);})['then'](function(_0x10a920){_0x51a303[_0x6eec('0x54')]=_0x10a920;return _0x51a303;});}})[_0x6eec('0x1f')](respondWithFilteredResult(_0x54de03,_0x50c99d))[_0x6eec('0x2a')](handleError(_0x54de03,null));};exports[_0x6eec('0xaa')]=function(_0x33eabf,_0x38a87a,_0x502a21){return db['OpenchannelAccount'][_0x6eec('0x57')]({'where':{'id':_0x33eabf[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x38a87a,null))['then'](function(_0x4d2a2e){if(_0x4d2a2e){return _0x4d2a2e['addAgents'](_0x33eabf['body']['ids'],_[_0x6eec('0xab')](_0x33eabf[_0x6eec('0x59')],[_0x6eec('0x67'),'id'])||{})['spread'](function(_0x200f9c){for(var _0x8d792f=0x0;_0x8d792f<_0x33eabf[_0x6eec('0x59')][_0x6eec('0x67')][_0x6eec('0x56')];_0x8d792f+=0x1){socket[_0x6eec('0xac')](_0x6eec('0xad'),{'UserId':_0x33eabf[_0x6eec('0x59')][_0x6eec('0x67')][_0x8d792f],'OpenchannelAccountId':_0x33eabf[_0x6eec('0x55')]['id']});}return _0x200f9c;});}})[_0x6eec('0x1f')](respondWithResult(_0x38a87a,null))[_0x6eec('0x2a')](handleError(_0x38a87a,null));};exports['removeAgents']=function(_0x334d6d,_0x2b1f6c,_0x2fe5d3){return db['OpenchannelAccount'][_0x6eec('0x57')]({'where':{'id':_0x334d6d['params']['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x2b1f6c,null))[_0x6eec('0x1f')](function(_0x2c109b){if(_0x2c109b){return _0x2c109b['removeAgents'](_0x334d6d[_0x6eec('0x44')][_0x6eec('0x67')])['then'](function(){if(_[_0x6eec('0xae')](_0x334d6d[_0x6eec('0x44')][_0x6eec('0x67')])){for(var _0x1eb705=0x0;_0x1eb705<_0x334d6d['query']['ids'][_0x6eec('0x56')];_0x1eb705+=0x1){socket[_0x6eec('0xac')](_0x6eec('0xaf'),{'UserId':Number(_0x334d6d[_0x6eec('0x44')][_0x6eec('0x67')][_0x1eb705]),'OpenchannelAccountId':Number(_0x334d6d[_0x6eec('0x55')]['id'])});}}else{socket[_0x6eec('0xac')](_0x6eec('0xaf'),{'UserId':Number(_0x334d6d[_0x6eec('0x44')]['ids']),'OpenchannelAccountId':Number(_0x334d6d[_0x6eec('0x55')]['id'])});}});}})[_0x6eec('0x1f')](respondWithStatusCode(_0x2b1f6c,null))['catch'](handleError(_0x2b1f6c,null));};exports[_0x6eec('0xb0')]=function(_0x100947,_0x23fb36,_0x1d9a0f){var _0x559ac0={};var _0x3511e8={};var _0x2cd1ba;var _0x4a84ff;return db[_0x6eec('0x3c')][_0x6eec('0x64')]({'where':{'id':_0x100947[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x23fb36,null))[_0x6eec('0x1f')](function(_0x58b36b){if(_0x58b36b){_0x2cd1ba=_0x58b36b;_0x3511e8['model']=_[_0x6eec('0x42')](db[_0x6eec('0x96')]['rawAttributes']);_0x3511e8[_0x6eec('0x44')]=_['keys'](_0x100947['query']);_0x3511e8[_0x6eec('0x4b')]=_[_0x6eec('0x43')](_0x3511e8[_0x6eec('0x40')],_0x3511e8[_0x6eec('0x44')]);_0x559ac0[_0x6eec('0x45')]=_[_0x6eec('0x43')](_0x3511e8['model'],qs['fields'](_0x100947[_0x6eec('0x44')][_0x6eec('0x46')]));_0x559ac0['attributes']=_0x559ac0[_0x6eec('0x45')]['length']?_0x559ac0['attributes']:_0x3511e8[_0x6eec('0x40')];_0x559ac0['order']=qs[_0x6eec('0x49')](_0x100947[_0x6eec('0x44')][_0x6eec('0x49')]);_0x559ac0[_0x6eec('0x4a')]=qs[_0x6eec('0x4b')](_[_0x6eec('0x4c')](_0x100947[_0x6eec('0x44')],_0x3511e8['filters']));if(_0x100947[_0x6eec('0x44')]['filter']){_0x559ac0[_0x6eec('0x4a')]=_['merge'](_0x559ac0['where'],{'$or':_[_0x6eec('0x41')](_0x559ac0['attributes'],function(_0x5e5e7d){var _0x2252e1={};_0x2252e1[_0x5e5e7d]={'$like':'%'+_0x100947[_0x6eec('0x44')][_0x6eec('0x4d')]+'%'};return _0x2252e1;})});}_0x559ac0=_[_0x6eec('0x4e')]({},_0x559ac0,_0x100947[_0x6eec('0x50')]);return _0x2cd1ba[_0x6eec('0xb0')](_0x559ac0);}})['then'](function(_0x194ec8){if(_0x194ec8){_0x4a84ff=_0x194ec8['length'];if(!_0x100947[_0x6eec('0x44')]['hasOwnProperty']('nolimit')){_0x559ac0[_0x6eec('0x30')]=qs[_0x6eec('0x30')](_0x100947[_0x6eec('0x44')][_0x6eec('0x30')]);_0x559ac0['offset']=qs[_0x6eec('0x2f')](_0x100947[_0x6eec('0x44')][_0x6eec('0x2f')]);}return _0x2cd1ba[_0x6eec('0xb0')](_0x559ac0);}})[_0x6eec('0x1f')](function(_0x5047b3){if(_0x5047b3){return _0x5047b3?{'count':_0x4a84ff,'rows':_0x5047b3}:null;}})[_0x6eec('0x1f')](respondWithResult(_0x23fb36,null))[_0x6eec('0x2a')](handleError(_0x23fb36,null));};exports[_0x6eec('0x39')]=function(_0x337602,_0x178a19,_0x28e1ee){var _0x36b8ac,_0x460821,_0x3ea97f;if(_[_0x6eec('0x73')](_0x337602[_0x6eec('0x59')]['body'])||_0x337602[_0x6eec('0x59')][_0x6eec('0x59')]===''){throw new db[(_0x6eec('0x6d'))]['ValidationError'](_0x6eec('0x74'));}if(_[_0x6eec('0x73')](_0x337602['body']['to'])){}_0x36b8ac=_0x337602[_0x6eec('0x59')]['to'];return db['OpenchannelAccount'][_0x6eec('0x64')]({'where':{'id':_0x337602[_0x6eec('0x55')]['id']}})[_0x6eec('0x1f')](handleEntityNotFound(_0x178a19,null))[_0x6eec('0x1f')](function(_0x21e29e){if(_0x21e29e){return db[_0x6eec('0x3c')]['find']({'where':{'id':_0x21e29e['id']},'include':[{'model':db[_0x6eec('0x78')],'as':_0x6eec('0x7d'),'include':[{'model':db['CmContact'],'as':_0x6eec('0x79'),'where':{[_0x21e29e[_0x6eec('0x75')]]:_0x36b8ac},'limit':0x1,'order':[['updatedAt',_0x6eec('0x7a')]]}]}]})['then'](handleEntityNotFound(_0x178a19,null))[_0x6eec('0x1f')](function(_0x5e350c){if(_0x5e350c&&_0x5e350c[_0x6eec('0x7d')]){_0x460821=_0x5e350c[_0x6eec('0x5c')]({'plain':!![]});if(_0x460821['List']&&_0x460821[_0x6eec('0x7d')][_0x6eec('0x79')][_0x6eec('0x56')]){return _0x460821[_0x6eec('0x7d')][_0x6eec('0x79')][0x0];}return db[_0x6eec('0x6c')][_0x6eec('0x58')](_['defaults'](_0x337602[_0x6eec('0x59')],{'firstName':_0x36b8ac,[_0x5e350c[_0x6eec('0x75')]]:_0x36b8ac,'phone':_0x36b8ac,'ListId':_0x460821[_0x6eec('0x84')]}));}})[_0x6eec('0x1f')](handleEntityNotFound(_0x178a19,null))[_0x6eec('0x1f')](function(_0x41ab79){if(_0x41ab79){_0x3ea97f=_0x41ab79;return db['OpenchannelInteraction'][_0x6eec('0x57')]({'where':{'ContactId':_0x3ea97f['id'],'closed':![],'OpenchannelAccountId':_0x460821['id']}})[_0x6eec('0x1f')](function(_0x4a5ed7){if(_0x4a5ed7){return[_0x4a5ed7,![]];}return db[_0x6eec('0x88')][_0x6eec('0x58')]({'UserId':_0x337602[_0x6eec('0x5a')]['id'],'ContactId':_0x3ea97f['id'],'OpenchannelAccountId':_0x460821['id'],'lastMsgDirection':'out','Messages':[_[_0x6eec('0x4e')](_0x337602[_0x6eec('0x59')],{'read':![],'body':_0x337602[_0x6eec('0x59')][_0x6eec('0x59')],'OpenchannelAccountId':_0x460821['id'],'UserId':_0x337602[_0x6eec('0x5a')]['id'],'ContactId':_0x3ea97f['id']})]},{'include':[{'model':db[_0x6eec('0x93')],'as':_0x6eec('0xb1')}]})[_0x6eec('0x1f')](function(_0x2241c0){return[_0x2241c0,!![]];});});}})[_0x6eec('0x8a')](function(_0x488a86,_0x3f76da){if(_0x3f76da){return _0x488a86;}return db[_0x6eec('0x93')]['create'](_[_0x6eec('0x4e')](_0x337602[_0x6eec('0x59')],{'read':![],'body':_0x337602[_0x6eec('0x59')][_0x6eec('0x59')],'OpenchannelAccountId':_0x460821['id'],'OpenchannelInteractionId':_0x488a86['id'],'UserId':_0x337602[_0x6eec('0x5a')]['id'],'ContactId':_0x3ea97f['id']}))[_0x6eec('0x1f')](function(_0x1825ff){_0x488a86['dataValues'][_0x6eec('0xb1')]=[];_0x488a86['dataValues'][_0x6eec('0xb1')]['push'](_0x1825ff[_0x6eec('0xb2')]);return _0x488a86;});});}})[_0x6eec('0x1f')](respondWithResult(_0x178a19,null))['catch'](handleError(_0x178a19,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