Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index 1ea9c57..95092f0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3d76=['where','filters','pick','merge','filter','count','includeAll','include','findAll','rows','show','params','options','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','addDisposition','Disposition','getDispositions','findOne','removeDispositions','CannedAnswer','getAnswers','removeAnswers','ids','notify','no\x20available\x20attributes','difference','createdAt','CompanyId','isNil','from','ValidationError','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','CmList','List','Contacts','updatedAt','DESC','OpenchannelApplication','Applications','applications','list','orderBy','asc','account','ListId','CmContact','firstName','threadId','externalUrl','OpenchannelInteraction','ContactId','spread','contact','lastName','messageId','interaction','created','push','unmanaged','OpenchannelMessage','AttachmentId','UserId','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','startRouting','Start','EventManager','sequelize','OpenchannelAccountId','bulkCreate','findAndCountAll','getApplications','getInteractions','Contact','User','fullname','Tags','color','tag','addAgents','emit','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','out','dataValues','html-pdf','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','path','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelAccount.socket','client','http','test','Sequelize','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','offset','set','apply','reject','save','update','OpenchannelAccounts','destroy','stack','name','send','Pause','mandatoryDispositionPause','map','OpenchannelAccount','rawAttributes','fieldName','type','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','limit','order','sort'];(function(_0x5f3f88,_0x562baf){var _0xd08119=function(_0x42dbf7){while(--_0x42dbf7){_0x5f3f88['push'](_0x5f3f88['shift']());}};_0xd08119(++_0x562baf);}(_0x3d76,0x1d8));var _0x63d7=function(_0x602ca8,_0x568e82){_0x602ca8=_0x602ca8-0x0;var _0x26e8ab=_0x3d76[_0x602ca8];return _0x26e8ab;};'use strict';var pdf=require(_0x63d7('0x0'));var emlformat=require(_0x63d7('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x63d7('0x2'));var rp=require(_0x63d7('0x3'));var moment=require(_0x63d7('0x4'));var BPromise=require(_0x63d7('0x5'));var Mustache=require(_0x63d7('0x6'));var util=require('util');var path=require(_0x63d7('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x63d7('0x8'));var fs=require('fs');var _=require(_0x63d7('0x9'));var squel=require(_0x63d7('0xa'));var crypto=require(_0x63d7('0xb'));var jsforce=require(_0x63d7('0xc'));var deskjs=require(_0x63d7('0xd'));var toCsv=require('to-csv');var querystring=require(_0x63d7('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x63d7('0xf'));var as=require(_0x63d7('0x10'));var hardwareService=require(_0x63d7('0x11'));var logger=require('../../config/logger')(_0x63d7('0x12'));var utils=require('../../config/utils');var config=require(_0x63d7('0x13'));var db=require(_0x63d7('0x14'))['db'];config[_0x63d7('0x15')]=_[_0x63d7('0x16')](config['redis'],{'host':_0x63d7('0x17'),'port':0x18eb});var socket=require(_0x63d7('0x18'))(new Redis(config['redis']));require(_0x63d7('0x19'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0x63d7('0x1a')][_0x63d7('0x1b')]({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});function checkPasswordPattern(_0x5ca234,_0x2bee1d,_0x469bf9){if(_0x469bf9){var _0x530302=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x530302[_0x63d7('0x1c')](_0x2bee1d)){return _0x5ca234;}else{throw new db[(_0x63d7('0x1d'))]['ValidationError'](_0x63d7('0x1e'));}}else{return _0x5ca234;}}function respondWithRpcPromise(_0x4ea4f2,_0x2c7ecd,_0xf700e5,_0x1c752f){return new BPromise(function(_0x5fc791,_0x40f322){var _0x33d93f=_0x1c752f||client;return _0x33d93f['request'](_0x4ea4f2,_0xf700e5)[_0x63d7('0x1f')](function(_0xef2952){logger[_0x63d7('0x20')](_0x63d7('0x21'),_0x2c7ecd,_0x63d7('0x22'));logger[_0x63d7('0x23')](_0x63d7('0x24'),_0x2c7ecd,'request\x20sent',JSON[_0x63d7('0x25')](_0xef2952));if(_0xef2952[_0x63d7('0x26')]){if(_0xef2952['error'][_0x63d7('0x27')]===0x1f4){logger[_0x63d7('0x26')](_0x63d7('0x21'),_0x2c7ecd,_0xef2952[_0x63d7('0x26')][_0x63d7('0x28')]);return _0x40f322(_0xef2952[_0x63d7('0x26')][_0x63d7('0x28')]);}logger[_0x63d7('0x26')](_0x63d7('0x21'),_0x2c7ecd,_0xef2952[_0x63d7('0x26')][_0x63d7('0x28')]);return _0x5fc791(_0xef2952[_0x63d7('0x26')][_0x63d7('0x28')]);}else{logger[_0x63d7('0x20')]('OpenchannelAccount,\x20%s,\x20%s',_0x2c7ecd,_0x63d7('0x22'));_0x5fc791(_0xef2952[_0x63d7('0x29')][_0x63d7('0x28')]);}})[_0x63d7('0x2a')](function(_0x37a3f1){logger['error'](_0x63d7('0x21'),_0x2c7ecd,_0x37a3f1);_0x40f322(_0x37a3f1);});});}function respondWithStatusCode(_0x1bf75c,_0x1f46cd){_0x1f46cd=_0x1f46cd||0xcc;return function(_0x457f2f){if(_0x457f2f){return _0x1bf75c[_0x63d7('0x2b')](_0x1f46cd);}return _0x1bf75c[_0x63d7('0x2c')](_0x1f46cd)[_0x63d7('0x2d')]();};}function respondWithResult(_0x4ed6c4,_0x56e9c5){_0x56e9c5=_0x56e9c5||0xc8;return function(_0x2f2f60){if(_0x2f2f60){return _0x4ed6c4[_0x63d7('0x2c')](_0x56e9c5)[_0x63d7('0x2e')](_0x2f2f60);}};}function respondWithFilteredResult(_0x31d76c,_0x44851d){return function(_0x4acdac){if(_0x4acdac){var _0x3391c5=_0x4acdac['count'],_0x2bce07=_0x44851d[_0x63d7('0x2f')],_0x42dd5f=_0x44851d[_0x63d7('0x2f')]+_0x44851d['limit'],_0x5a9a2a;if(_0x42dd5f>=_0x3391c5){_0x42dd5f=_0x3391c5;_0x5a9a2a=0xc8;}else{_0x5a9a2a=0xce;}_0x31d76c[_0x63d7('0x2c')](_0x5a9a2a);return _0x31d76c[_0x63d7('0x30')]('Content-Range',_0x2bce07+'-'+_0x42dd5f+'/'+_0x3391c5)[_0x63d7('0x2e')](_0x4acdac);}return null;};}function patchUpdates(_0x22ada0){return function(_0x835200){try{jsonpatch[_0x63d7('0x31')](_0x835200,_0x22ada0,!![]);}catch(_0x38ffaf){return BPromise[_0x63d7('0x32')](_0x38ffaf);}return _0x835200[_0x63d7('0x33')]();};}function saveUpdates(_0x403104,_0x5d26f3){return function(_0x45a247){if(_0x45a247){return _0x45a247[_0x63d7('0x34')](_0x403104)[_0x63d7('0x1f')](function(_0x26c18c){return _0x26c18c;});}return null;};}function removeEntity(_0x33d6cf,_0x4af9d9){return function(_0x4492fa){if(_0x4492fa){return _0x4492fa['destroy']()[_0x63d7('0x1f')](function(){var _0x1485b3=_0x4492fa['get']({'plain':!![]});var _0x4842bb=_0x63d7('0x35');return db['UserProfileResource'][_0x63d7('0x36')]({'where':{'type':_0x4842bb,'resourceId':_0x1485b3['id']}})[_0x63d7('0x1f')](function(){return _0x4492fa;});})[_0x63d7('0x1f')](function(){_0x33d6cf['status'](0xcc)[_0x63d7('0x2d')]();});}};}function handleEntityNotFound(_0x1defde,_0x3c6e88){return function(_0x1761d9){if(!_0x1761d9){_0x1defde['sendStatus'](0x194);}return _0x1761d9;};}function handleError(_0x839325,_0x40f0fa){_0x40f0fa=_0x40f0fa||0x1f4;return function(_0x5bbee0){logger[_0x63d7('0x26')](_0x5bbee0[_0x63d7('0x37')]);if(_0x5bbee0[_0x63d7('0x38')]){delete _0x5bbee0[_0x63d7('0x38')];}_0x839325[_0x63d7('0x2c')](_0x40f0fa)[_0x63d7('0x39')](_0x5bbee0);};}exports['index']=function(_0x2bbca4,_0x414229){var _0x37fd6d={'include':[{'model':db[_0x63d7('0x3a')],'as':_0x63d7('0x3b')}]},_0x3926ed={},_0x23553e={'count':0x0,'rows':[]};var _0x3e909f=_[_0x63d7('0x3c')](db[_0x63d7('0x3d')][_0x63d7('0x3e')],function(_0x12e175){return{'name':_0x12e175[_0x63d7('0x3f')],'type':_0x12e175[_0x63d7('0x40')]['key']};});_0x3926ed[_0x63d7('0x41')]=_[_0x63d7('0x3c')](_0x3e909f,_0x63d7('0x38'));_0x3926ed[_0x63d7('0x42')]=_[_0x63d7('0x43')](_0x2bbca4[_0x63d7('0x42')]);_0x3926ed['filters']=_['intersection'](_0x3926ed[_0x63d7('0x41')],_0x3926ed['query']);_0x37fd6d[_0x63d7('0x44')]=_[_0x63d7('0x45')](_0x3926ed[_0x63d7('0x41')],qs[_0x63d7('0x46')](_0x2bbca4['query'][_0x63d7('0x46')]));_0x37fd6d[_0x63d7('0x44')]=_0x37fd6d[_0x63d7('0x44')][_0x63d7('0x47')]?_0x37fd6d[_0x63d7('0x44')]:_0x3926ed[_0x63d7('0x41')];if(!_0x2bbca4[_0x63d7('0x42')][_0x63d7('0x48')](_0x63d7('0x49'))){_0x37fd6d[_0x63d7('0x4a')]=qs[_0x63d7('0x4a')](_0x2bbca4[_0x63d7('0x42')][_0x63d7('0x4a')]);_0x37fd6d[_0x63d7('0x2f')]=qs['offset'](_0x2bbca4['query'][_0x63d7('0x2f')]);}_0x37fd6d[_0x63d7('0x4b')]=qs[_0x63d7('0x4c')](_0x2bbca4[_0x63d7('0x42')][_0x63d7('0x4c')]);_0x37fd6d[_0x63d7('0x4d')]=qs[_0x63d7('0x4e')](_[_0x63d7('0x4f')](_0x2bbca4[_0x63d7('0x42')],_0x3926ed['filters']));if(_0x2bbca4[_0x63d7('0x42')]['filter']){_0x37fd6d[_0x63d7('0x4d')]=_[_0x63d7('0x50')](_0x37fd6d[_0x63d7('0x4d')],{'$or':_[_0x63d7('0x3c')](_0x3e909f,function(_0x220955){if(_0x220955[_0x63d7('0x40')]!=='VIRTUAL'){var _0x5afa2c={};_0x5afa2c[_0x220955[_0x63d7('0x38')]]={'$like':'%'+_0x2bbca4[_0x63d7('0x42')][_0x63d7('0x51')]+'%'};return _0x5afa2c;}})});}_0x37fd6d=_[_0x63d7('0x50')]({},_0x37fd6d,_0x2bbca4['options']);var _0x3acf7f={'where':_0x37fd6d[_0x63d7('0x4d')]};return db[_0x63d7('0x3d')][_0x63d7('0x52')](_0x3acf7f)[_0x63d7('0x1f')](function(_0x356794){_0x23553e[_0x63d7('0x52')]=_0x356794;if(_0x2bbca4[_0x63d7('0x42')][_0x63d7('0x53')]){_0x37fd6d[_0x63d7('0x54')]=[{'all':!![]}];}return db['OpenchannelAccount'][_0x63d7('0x55')](_0x37fd6d);})[_0x63d7('0x1f')](function(_0x42b1cc){_0x23553e[_0x63d7('0x56')]=_0x42b1cc;return _0x23553e;})[_0x63d7('0x1f')](respondWithFilteredResult(_0x414229,_0x37fd6d))[_0x63d7('0x2a')](handleError(_0x414229,null));};exports[_0x63d7('0x57')]=function(_0x23e5a3,_0x34533b){var _0x41c93d={'raw':![],'where':{'id':_0x23e5a3[_0x63d7('0x58')]['id']},'include':[{'model':db[_0x63d7('0x3a')],'as':_0x63d7('0x3b')}]},_0x3e6cf2={};_0x3e6cf2[_0x63d7('0x41')]=_['keys'](db['OpenchannelAccount']['rawAttributes']);_0x3e6cf2[_0x63d7('0x42')]=_['keys'](_0x23e5a3['query']);_0x3e6cf2[_0x63d7('0x4e')]=_['intersection'](_0x3e6cf2['model'],_0x3e6cf2['query']);_0x41c93d[_0x63d7('0x44')]=_[_0x63d7('0x45')](_0x3e6cf2[_0x63d7('0x41')],qs[_0x63d7('0x46')](_0x23e5a3['query'][_0x63d7('0x46')]));_0x41c93d[_0x63d7('0x44')]=_0x41c93d[_0x63d7('0x44')][_0x63d7('0x47')]?_0x41c93d['attributes']:_0x3e6cf2[_0x63d7('0x41')];if(_0x23e5a3[_0x63d7('0x42')][_0x63d7('0x53')]){_0x41c93d[_0x63d7('0x54')]=[{'all':!![]}];}_0x41c93d=_[_0x63d7('0x50')]({},_0x41c93d,_0x23e5a3[_0x63d7('0x59')]);return db[_0x63d7('0x3d')]['find'](_0x41c93d)['then'](handleEntityNotFound(_0x34533b,null))['then'](respondWithResult(_0x34533b,null))[_0x63d7('0x2a')](handleError(_0x34533b,null));};exports[_0x63d7('0x5a')]=function(_0x572979,_0x5dfa89){return db[_0x63d7('0x3d')][_0x63d7('0x5a')](_0x572979['body'],{})[_0x63d7('0x1f')](function(_0x49d9da){var _0x1ac764=_0x572979[_0x63d7('0x5b')][_0x63d7('0x5c')]({'plain':!![]});if(!_0x1ac764)throw new Error(_0x63d7('0x5d'));if(_0x1ac764['role']===_0x63d7('0x5b')){var _0x4dae68=_0x49d9da[_0x63d7('0x5c')]({'plain':!![]});var _0x32bb3c=_0x63d7('0x35');return db[_0x63d7('0x5e')][_0x63d7('0x5f')]({'where':{'name':_0x32bb3c,'userProfileId':_0x1ac764[_0x63d7('0x60')]},'raw':!![]})[_0x63d7('0x1f')](function(_0x3224e7){if(_0x3224e7&&_0x3224e7[_0x63d7('0x61')]===0x0){return db[_0x63d7('0x62')][_0x63d7('0x5a')]({'name':_0x4dae68[_0x63d7('0x38')],'resourceId':_0x4dae68['id'],'type':_0x3224e7[_0x63d7('0x38')],'sectionId':_0x3224e7['id']},{})['then'](function(){return _0x49d9da;});}else{return _0x49d9da;}})[_0x63d7('0x2a')](function(_0x3d0453){logger['error'](_0x63d7('0x63'),_0x3d0453);throw _0x3d0453;});}return _0x49d9da;})[_0x63d7('0x1f')](respondWithResult(_0x5dfa89,0xc9))[_0x63d7('0x2a')](handleError(_0x5dfa89,null));};exports[_0x63d7('0x34')]=function(_0x3ec4a1,_0x4ff136){if(_0x3ec4a1[_0x63d7('0x64')]['id']){delete _0x3ec4a1['body']['id'];}return db[_0x63d7('0x3d')][_0x63d7('0x5f')]({'where':{'id':_0x3ec4a1[_0x63d7('0x58')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]})[_0x63d7('0x1f')](handleEntityNotFound(_0x4ff136,null))[_0x63d7('0x1f')](saveUpdates(_0x3ec4a1[_0x63d7('0x64')],null))[_0x63d7('0x1f')](respondWithResult(_0x4ff136,null))[_0x63d7('0x2a')](handleError(_0x4ff136,null));};exports[_0x63d7('0x36')]=function(_0x59481a,_0xc2fe0f){return db[_0x63d7('0x3d')][_0x63d7('0x5f')]({'where':{'id':_0x59481a[_0x63d7('0x58')]['id']}})[_0x63d7('0x1f')](handleEntityNotFound(_0xc2fe0f,null))[_0x63d7('0x1f')](removeEntity(_0xc2fe0f,null))[_0x63d7('0x2a')](handleError(_0xc2fe0f,null));};exports[_0x63d7('0x65')]=function(_0x5863f9,_0x26fa6c){return db[_0x63d7('0x3d')][_0x63d7('0x65')]()[_0x63d7('0x1f')](respondWithResult(_0x26fa6c,null))[_0x63d7('0x2a')](handleError(_0x26fa6c,null));};exports[_0x63d7('0x66')]=function(_0x2b0efc,_0x7f5ac,_0x3cdef5){if(_0x2b0efc[_0x63d7('0x64')]['id']){delete _0x2b0efc[_0x63d7('0x64')]['id'];}return db[_0x63d7('0x3d')][_0x63d7('0x5f')]({'where':{'id':_0x2b0efc[_0x63d7('0x58')]['id']}})[_0x63d7('0x1f')](handleEntityNotFound(_0x7f5ac,null))[_0x63d7('0x1f')](function(_0x2b1732){if(_0x2b1732){_0x2b0efc[_0x63d7('0x64')]['OpnechannelAccountId']=_0x2b1732['id'];return db[_0x63d7('0x67')][_0x63d7('0x5a')](_0x2b0efc[_0x63d7('0x64')]);}})[_0x63d7('0x1f')](respondWithResult(_0x7f5ac,null))[_0x63d7('0x2a')](handleError(_0x7f5ac,null));};exports[_0x63d7('0x68')]=function(_0xe7cdde,_0x4d5e08,_0x39833b){var _0x57781c={'raw':![],'where':{}};var _0x1051a3={};var _0x109fbe={'count':0x0,'rows':[]};return db[_0x63d7('0x3d')][_0x63d7('0x69')]({'where':{'id':_0xe7cdde['params']['id']}})['then'](handleEntityNotFound(_0x4d5e08,null))[_0x63d7('0x1f')](function(_0x2c1e76){if(_0x2c1e76){_0x1051a3['model']=_[_0x63d7('0x43')](db[_0x63d7('0x67')]['rawAttributes']);_0x1051a3[_0x63d7('0x42')]=_[_0x63d7('0x43')](_0xe7cdde[_0x63d7('0x42')]);_0x1051a3[_0x63d7('0x4e')]=_['intersection'](_0x1051a3['model'],_0x1051a3[_0x63d7('0x42')]);_0x57781c[_0x63d7('0x44')]=_[_0x63d7('0x45')](_0x1051a3['model'],qs[_0x63d7('0x46')](_0xe7cdde[_0x63d7('0x42')]['fields']));_0x57781c['attributes']=_0x57781c[_0x63d7('0x44')][_0x63d7('0x47')]?_0x57781c['attributes']:_0x1051a3[_0x63d7('0x41')];if(!_0xe7cdde[_0x63d7('0x42')][_0x63d7('0x48')]('nolimit')){_0x57781c[_0x63d7('0x4a')]=qs[_0x63d7('0x4a')](_0xe7cdde[_0x63d7('0x42')][_0x63d7('0x4a')]);_0x57781c['offset']=qs[_0x63d7('0x2f')](_0xe7cdde[_0x63d7('0x42')][_0x63d7('0x2f')]);}_0x57781c[_0x63d7('0x4b')]=qs[_0x63d7('0x4c')](_0xe7cdde[_0x63d7('0x42')][_0x63d7('0x4c')]);_0x57781c[_0x63d7('0x4d')]=qs['filters'](_[_0x63d7('0x4f')](_0xe7cdde[_0x63d7('0x42')],_0x1051a3[_0x63d7('0x4e')]));_0x57781c[_0x63d7('0x4d')]['OpenchannelAccountId']=_0x2c1e76['id'];if(_0xe7cdde[_0x63d7('0x42')][_0x63d7('0x51')]){_0x57781c['where']=_[_0x63d7('0x50')](_0x57781c[_0x63d7('0x4d')],{'$or':_[_0x63d7('0x3c')](_0x57781c['attributes'],function(_0x302d04){var _0x1745ca={};_0x1745ca[_0x302d04]={'$like':'%'+_0xe7cdde['query'][_0x63d7('0x51')]+'%'};return _0x1745ca;})});}_0x57781c=_[_0x63d7('0x50')]({},_0x57781c,_0xe7cdde[_0x63d7('0x59')]);return db[_0x63d7('0x67')][_0x63d7('0x52')]({'where':_0x57781c['where']})[_0x63d7('0x1f')](function(_0x2e42ff){_0x109fbe[_0x63d7('0x52')]=_0x2e42ff;if(_0xe7cdde['query'][_0x63d7('0x53')]){_0x57781c[_0x63d7('0x54')]=[{'all':!![]}];}return db[_0x63d7('0x67')][_0x63d7('0x55')](_0x57781c);})['then'](function(_0xad8b18){_0x109fbe['rows']=_0xad8b18;return _0x109fbe;});}})[_0x63d7('0x1f')](respondWithFilteredResult(_0x4d5e08,_0x57781c))[_0x63d7('0x2a')](handleError(_0x4d5e08,null));};exports['removeDispositions']=function(_0x2a28e7,_0xc764c0,_0x3ae31a){return db[_0x63d7('0x3d')]['find']({'where':{'id':_0x2a28e7['params']['id']}})[_0x63d7('0x1f')](handleEntityNotFound(_0xc764c0,null))[_0x63d7('0x1f')](function(_0x5956c6){if(_0x5956c6){return _0x5956c6[_0x63d7('0x6a')](_0x2a28e7[_0x63d7('0x42')]['ids']);}})[_0x63d7('0x1f')](respondWithStatusCode(_0xc764c0,null))['catch'](handleError(_0xc764c0,null));};exports['addAnswer']=function(_0x4dface,_0x707f08,_0x5e1a13){if(_0x4dface[_0x63d7('0x64')]['id']){delete _0x4dface[_0x63d7('0x64')]['id'];}return db[_0x63d7('0x3d')][_0x63d7('0x5f')]({'where':{'id':_0x4dface[_0x63d7('0x58')]['id']}})[_0x63d7('0x1f')](handleEntityNotFound(_0x707f08,null))[_0x63d7('0x1f')](function(_0x885b46){if(_0x885b46){_0x4dface[_0x63d7('0x64')]['OpenchannelAccountId']=_0x885b46['id'];return db[_0x63d7('0x6b')][_0x63d7('0x5a')](_0x4dface[_0x63d7('0x64')]);}})['then'](respondWithResult(_0x707f08,null))['catch'](handleError(_0x707f08,null));};exports[_0x63d7('0x6c')]=function(_0x4dbd1a,_0x7bce0c,_0x440941){var _0xa01b43={'raw':![],'where':{}};var _0x4fadca={};var _0x379d46={'count':0x0,'rows':[]};return db[_0x63d7('0x3d')][_0x63d7('0x69')]({'where':{'id':_0x4dbd1a[_0x63d7('0x58')]['id']}})['then'](handleEntityNotFound(_0x7bce0c,null))[_0x63d7('0x1f')](function(_0xfc02a){if(_0xfc02a){_0x4fadca[_0x63d7('0x41')]=_[_0x63d7('0x43')](db[_0x63d7('0x6b')]['rawAttributes']);_0x4fadca['query']=_[_0x63d7('0x43')](_0x4dbd1a[_0x63d7('0x42')]);_0x4fadca[_0x63d7('0x4e')]=_[_0x63d7('0x45')](_0x4fadca['model'],_0x4fadca[_0x63d7('0x42')]);_0xa01b43[_0x63d7('0x44')]=_['intersection'](_0x4fadca[_0x63d7('0x41')],qs[_0x63d7('0x46')](_0x4dbd1a[_0x63d7('0x42')][_0x63d7('0x46')]));_0xa01b43[_0x63d7('0x44')]=_0xa01b43[_0x63d7('0x44')][_0x63d7('0x47')]?_0xa01b43[_0x63d7('0x44')]:_0x4fadca[_0x63d7('0x41')];if(!_0x4dbd1a[_0x63d7('0x42')][_0x63d7('0x48')](_0x63d7('0x49'))){_0xa01b43[_0x63d7('0x4a')]=qs[_0x63d7('0x4a')](_0x4dbd1a['query'][_0x63d7('0x4a')]);_0xa01b43[_0x63d7('0x2f')]=qs[_0x63d7('0x2f')](_0x4dbd1a['query'][_0x63d7('0x2f')]);}_0xa01b43[_0x63d7('0x4b')]=qs[_0x63d7('0x4c')](_0x4dbd1a[_0x63d7('0x42')][_0x63d7('0x4c')]);_0xa01b43[_0x63d7('0x4d')]=qs[_0x63d7('0x4e')](_[_0x63d7('0x4f')](_0x4dbd1a['query'],_0x4fadca['filters']));_0xa01b43['where']['OpenchannelAccountId']=_0xfc02a['id'];if(_0x4dbd1a[_0x63d7('0x42')][_0x63d7('0x51')]){_0xa01b43[_0x63d7('0x4d')]=_[_0x63d7('0x50')](_0xa01b43[_0x63d7('0x4d')],{'$or':_[_0x63d7('0x3c')](_0xa01b43[_0x63d7('0x44')],function(_0x12ac26){var _0x1a778f={};_0x1a778f[_0x12ac26]={'$like':'%'+_0x4dbd1a[_0x63d7('0x42')][_0x63d7('0x51')]+'%'};return _0x1a778f;})});}_0xa01b43=_['merge']({},_0xa01b43,_0x4dbd1a[_0x63d7('0x59')]);return db[_0x63d7('0x6b')][_0x63d7('0x52')]({'where':_0xa01b43['where']})[_0x63d7('0x1f')](function(_0x33969a){_0x379d46[_0x63d7('0x52')]=_0x33969a;if(_0x4dbd1a[_0x63d7('0x42')][_0x63d7('0x53')]){_0xa01b43[_0x63d7('0x54')]=[{'all':!![]}];}return db[_0x63d7('0x6b')]['findAll'](_0xa01b43);})[_0x63d7('0x1f')](function(_0xfefdf3){_0x379d46[_0x63d7('0x56')]=_0xfefdf3;return _0x379d46;});}})[_0x63d7('0x1f')](respondWithFilteredResult(_0x7bce0c,_0xa01b43))['catch'](handleError(_0x7bce0c,null));};exports[_0x63d7('0x6d')]=function(_0x19146c,_0x5c3174,_0x4f4b87){return db[_0x63d7('0x3d')][_0x63d7('0x5f')]({'where':{'id':_0x19146c[_0x63d7('0x58')]['id']}})['then'](handleEntityNotFound(_0x5c3174,null))['then'](function(_0x2dfdfb){if(_0x2dfdfb){return _0x2dfdfb[_0x63d7('0x6d')](_0x19146c['query'][_0x63d7('0x6e')]);}})['then'](respondWithStatusCode(_0x5c3174,null))['catch'](handleError(_0x5c3174,null));};exports[_0x63d7('0x6f')]=function(_0x3d161b,_0x38cd91,_0x4a045e){var _0x72be6c={'body':_0x3d161b[_0x63d7('0x64')],'channel':'openchannel'};var _0x3d4259=[];var _0x1a3472=[];var _0x47eb62={};var _0x305a1e=![];return db['CmContact'][_0x63d7('0x65')]()[_0x63d7('0x1f')](function(_0x450c65){if(!_0x450c65){throw new db[(_0x63d7('0x1d'))]['ValidationError'](_0x63d7('0x70'));}_0x3d4259=_[_0x63d7('0x71')](_[_0x63d7('0x43')](_0x450c65),[_0x63d7('0x72'),'updatedAt']);_0x1a3472=_[_0x63d7('0x71')](_['keys'](_0x450c65),[_0x63d7('0x72'),'updatedAt',_0x63d7('0x73'),'ListId']);if(_0x3d161b[_0x63d7('0x64')]['id']){delete _0x3d161b[_0x63d7('0x64')]['id'];}if(_[_0x63d7('0x74')](_0x3d161b[_0x63d7('0x64')][_0x63d7('0x75')])){throw new db[(_0x63d7('0x1d'))][(_0x63d7('0x76'))](_0x63d7('0x77'));}if(_['isNil'](_0x3d161b[_0x63d7('0x64')][_0x63d7('0x64')])||_0x3d161b[_0x63d7('0x64')][_0x63d7('0x64')]===''){throw new db[(_0x63d7('0x1d'))][(_0x63d7('0x76'))](_0x63d7('0x78'));}if(_[_0x63d7('0x74')](_0x3d161b[_0x63d7('0x64')][_0x63d7('0x79')])){throw new db['Sequelize'][(_0x63d7('0x76'))](_0x63d7('0x7a')+_0x1a3472);}if(!_[_0x63d7('0x7b')](_0x1a3472,_0x3d161b[_0x63d7('0x64')]['mapKey'])){throw new db[(_0x63d7('0x1d'))][(_0x63d7('0x76'))](_0x63d7('0x7c')+_0x1a3472);}_0x47eb62[_0x3d161b[_0x63d7('0x64')][_0x63d7('0x79')]]=_0x3d161b['body'][_0x63d7('0x75')];})[_0x63d7('0x1f')](function(){return db[_0x63d7('0x3d')][_0x63d7('0x5f')]({'where':{'id':_0x3d161b[_0x63d7('0x58')]['id']},'include':[{'model':db[_0x63d7('0x7d')],'as':_0x63d7('0x7e'),'include':[{'model':db['CmContact'],'as':_0x63d7('0x7f'),'where':_0x47eb62,'limit':0x1,'order':[[_0x63d7('0x80'),_0x63d7('0x81')]]}]},{'model':db[_0x63d7('0x82')],'as':_0x63d7('0x83')}]});})['then'](handleEntityNotFound(_0x38cd91,null))[_0x63d7('0x1f')](function(_0x40d133){if(_0x40d133&&_0x40d133[_0x63d7('0x7e')]){_0x72be6c['account']=_0x40d133;_0x72be6c[_0x63d7('0x84')]=_0x40d133['Applications'];_0x72be6c[_0x63d7('0x85')]=_0x40d133[_0x63d7('0x7e')];_0x72be6c[_0x63d7('0x84')]=_[_0x63d7('0x86')](_0x72be6c[_0x63d7('0x84')],['priority'],[_0x63d7('0x87')]);if(_0x72be6c['account'][_0x63d7('0x83')]){delete _0x72be6c[_0x63d7('0x88')][_0x63d7('0x83')];}if(_0x72be6c[_0x63d7('0x88')][_0x63d7('0x7e')]&&_0x72be6c['account'][_0x63d7('0x7e')][_0x63d7('0x7f')][_0x63d7('0x47')]){return _0x72be6c[_0x63d7('0x88')][_0x63d7('0x7e')]['Contacts'][0x0];}var _0x1caa22=_[_0x63d7('0x16')](_0x3d161b[_0x63d7('0x64')],{'firstName':_0x3d161b[_0x63d7('0x64')][_0x63d7('0x75')],'ListId':_0x40d133[_0x63d7('0x89')]});_0x1caa22[_0x3d161b[_0x63d7('0x64')]['mapKey']]=_0x3d161b[_0x63d7('0x64')][_0x63d7('0x75')];return db[_0x63d7('0x8a')][_0x63d7('0x5a')](_0x1caa22,{'fields':_0x3d4259,'raw':!![]});}})['then'](handleEntityNotFound(_0x38cd91,null))[_0x63d7('0x1f')](function(_0x175691){_0x72be6c['contact']=_0x175691;if(_0x175691){var _0x144760={'ContactId':_0x175691['id'],'OpenchannelAccountId':_0x3d161b['params']['id'],'from':(_0x175691[_0x63d7('0x8b')]||'')+'\x20'+(_0x175691['lastName']||'')};var _0x316ce8={'OpenchannelAccountId':_0x3d161b['params']['id'],'closed':![]};if(_0x3d161b[_0x63d7('0x64')][_0x63d7('0x8c')]){_0x316ce8[_0x63d7('0x8c')]=_0x3d161b[_0x63d7('0x64')][_0x63d7('0x8c')];return db['OpenchannelInteraction']['find']({'where':_0x316ce8})[_0x63d7('0x1f')](function(_0x31ee3f){if(_0x31ee3f){return[_0x31ee3f,![]];}_0x144760['threadId']=_0x3d161b[_0x63d7('0x64')][_0x63d7('0x8c')];_0x144760[_0x63d7('0x8d')]=_0x3d161b[_0x63d7('0x64')][_0x63d7('0x8d')];return db[_0x63d7('0x8e')][_0x63d7('0x5a')](_0x144760)[_0x63d7('0x1f')](function(_0x4e6acc){return[_0x4e6acc,!![]];});});}else{_0x316ce8[_0x63d7('0x8c')]=null;}_0x316ce8[_0x63d7('0x8f')]=_0x175691['id'];return db[_0x63d7('0x8e')][_0x63d7('0x5f')]({'where':_0x316ce8})[_0x63d7('0x1f')](function(_0x1a67c4){if(_0x1a67c4){return[_0x1a67c4,![]];}return db[_0x63d7('0x8e')][_0x63d7('0x5a')](_0x144760)[_0x63d7('0x1f')](function(_0x4ee337){return[_0x4ee337,!![]];});});}})[_0x63d7('0x90')](function(_0x7238f,_0x3bcf10){if(_0x7238f){_0x305a1e=_0x3bcf10;if(!_0x3bcf10){var _0x58fb68={'from':(_0x72be6c[_0x63d7('0x91')]['firstName']||'')+'\x20'+(_0x72be6c[_0x63d7('0x91')][_0x63d7('0x92')]||'')};if(_0x3d161b[_0x63d7('0x64')]['threadId']&&_0x3d161b[_0x63d7('0x64')][_0x63d7('0x93')]&&_0x3d161b['body'][_0x63d7('0x8c')]!=_0x3d161b[_0x63d7('0x64')][_0x63d7('0x93')]){_0x58fb68['threadId']=_0x3d161b['body'][_0x63d7('0x93')];}return _0x7238f[_0x63d7('0x34')](_0x58fb68);}else{return _0x7238f;}}})[_0x63d7('0x1f')](function(_0x627d21){_0x72be6c[_0x63d7('0x94')]=_0x627d21['get']({'plain':!![]});_0x72be6c[_0x63d7('0x94')][_0x63d7('0x95')]=_0x305a1e;if(_0x72be6c[_0x63d7('0x94')][_0x63d7('0x95')]){if(_0x72be6c[_0x63d7('0x88')]['autoclose']){_0x72be6c[_0x63d7('0x84')][_0x63d7('0x96')]({'id':0x0,'priority':_0x72be6c[_0x63d7('0x84')][_0x63d7('0x47')]+0x1,'app':'close','appdata':_0x63d7('0x97'),'interval':'*,*,*,*'});}}return db[_0x63d7('0x98')][_0x63d7('0x5a')]({'body':_0x3d161b[_0x63d7('0x64')]['body'],'OpenchannelAccountId':_0x3d161b[_0x63d7('0x58')]['id'],'OpenchannelInteractionId':_0x627d21['id'],'direction':'in','ContactId':_0x72be6c[_0x63d7('0x91')]['id'],'AttachmentId':_0x3d161b[_0x63d7('0x64')][_0x63d7('0x99')]});})[_0x63d7('0x1f')](function(_0x3eec2a){_0x72be6c[_0x63d7('0x28')]=_0x3eec2a;if(_0x72be6c[_0x63d7('0x94')][_0x63d7('0x9a')]){return db['User'][_0x63d7('0x5f')]({'attributes':['id',_0x63d7('0x38')],'where':{'id':_0x72be6c[_0x63d7('0x94')][_0x63d7('0x9a')]}})['then'](function(_0x3fdec8){if(_0x3fdec8){_0x72be6c[_0x63d7('0x84')][_0x63d7('0x9b')]({'id':0x0,'priority':0x0,'app':_0x63d7('0x9c'),'appdata':_0x3fdec8[_0x63d7('0x38')]+','+(_0x72be6c[_0x63d7('0x88')][_0x63d7('0x9d')]||0xa),'interval':_0x63d7('0x9e')});_0x72be6c[_0x63d7('0x9f')]=![];}return respondWithRpcPromise('Start',_0x63d7('0xa0'),_0x72be6c);});}return respondWithRpcPromise(_0x63d7('0xa1'),_0x63d7('0xa0'),_0x72be6c);})[_0x63d7('0x1f')](function(_0x48d284){respondWithRpcPromise('EventManager',_0x63d7('0xa2'),{'event':_0x63d7('0x6f'),'message':_0x48d284},client9002);return _0x48d284;})[_0x63d7('0x1f')](respondWithResult(_0x38cd91,null))[_0x63d7('0x2a')](handleError(_0x38cd91,null));};exports['addApplications']=function(_0x3c888e,_0xa66d90,_0x3dd676){return db[_0x63d7('0x3d')][_0x63d7('0x69')]({'where':{'id':_0x3c888e['params']['id']}})[_0x63d7('0x1f')](handleEntityNotFound(_0xa66d90,null))['then'](function(_0x376711){if(_0x376711){return db[_0x63d7('0xa3')]['transaction'](function(_0x51c328){return db[_0x63d7('0x82')]['destroy']({'where':{'OpenchannelAccountId':_0x3c888e[_0x63d7('0x58')]['id']},'transaction':_0x51c328})[_0x63d7('0x1f')](function(_0x1efe89){var _0x52f53c=_[_0x63d7('0x3c')](_0x3c888e[_0x63d7('0x64')],function(_0x5ce0b8){_0x5ce0b8[_0x63d7('0xa4')]=_0x3c888e[_0x63d7('0x58')]['id'];return _0x5ce0b8;});return db[_0x63d7('0x82')][_0x63d7('0xa5')](_0x52f53c,{'transaction':_0x51c328});});})[_0x63d7('0x1f')](function(){return db[_0x63d7('0x82')][_0x63d7('0xa6')]({'where':{'OpenchannelAccountId':_0x3c888e['params']['id']},'order':'priority'});});}})['then'](respondWithResult(_0xa66d90,null))[_0x63d7('0x2a')](handleError(_0xa66d90,null));};exports[_0x63d7('0xa7')]=function(_0x1acc6e,_0x5c623c,_0x597d70){var _0x5bd991={};var _0x226733={};var _0xe1fc8c;var _0x4d4191;return db['OpenchannelAccount']['findOne']({'where':{'id':_0x1acc6e[_0x63d7('0x58')]['id']}})['then'](handleEntityNotFound(_0x5c623c,null))['then'](function(_0x26148f){if(_0x26148f){_0xe1fc8c=_0x26148f;_0x226733['model']=_[_0x63d7('0x43')](db[_0x63d7('0x82')][_0x63d7('0x3e')]);_0x226733['query']=_[_0x63d7('0x43')](_0x1acc6e[_0x63d7('0x42')]);_0x226733[_0x63d7('0x4e')]=_['intersection'](_0x226733['model'],_0x226733[_0x63d7('0x42')]);_0x5bd991[_0x63d7('0x44')]=_['intersection'](_0x226733[_0x63d7('0x41')],qs[_0x63d7('0x46')](_0x1acc6e[_0x63d7('0x42')][_0x63d7('0x46')]));_0x5bd991[_0x63d7('0x44')]=_0x5bd991['attributes'][_0x63d7('0x47')]?_0x5bd991[_0x63d7('0x44')]:_0x226733[_0x63d7('0x41')];_0x5bd991[_0x63d7('0x4b')]=qs[_0x63d7('0x4c')](_0x1acc6e['query'][_0x63d7('0x4c')]);_0x5bd991['where']=qs[_0x63d7('0x4e')](_[_0x63d7('0x4f')](_0x1acc6e[_0x63d7('0x42')],_0x226733['filters']));if(_0x1acc6e[_0x63d7('0x42')][_0x63d7('0x51')]){_0x5bd991[_0x63d7('0x4d')]=_[_0x63d7('0x50')](_0x5bd991['where'],{'$or':_['map'](_0x5bd991[_0x63d7('0x44')],function(_0x292a29){var _0x3d98b8={};_0x3d98b8[_0x292a29]={'$like':'%'+_0x1acc6e['query'][_0x63d7('0x51')]+'%'};return _0x3d98b8;})});}_0x5bd991=_['merge']({},_0x5bd991,_0x1acc6e['options']);return _0xe1fc8c['getApplications'](_0x5bd991);}})[_0x63d7('0x1f')](function(_0x2e6eb1){if(_0x2e6eb1){_0x4d4191=_0x2e6eb1[_0x63d7('0x47')];if(!_0x1acc6e[_0x63d7('0x42')][_0x63d7('0x48')](_0x63d7('0x49'))){_0x5bd991[_0x63d7('0x4a')]=qs['limit'](_0x1acc6e[_0x63d7('0x42')][_0x63d7('0x4a')]);_0x5bd991[_0x63d7('0x2f')]=qs['offset'](_0x1acc6e['query'][_0x63d7('0x2f')]);}return _0xe1fc8c[_0x63d7('0xa7')](_0x5bd991);}})[_0x63d7('0x1f')](function(_0x4f2546){if(_0x4f2546){return _0x4f2546?{'count':_0x4d4191,'rows':_0x4f2546}:null;}})[_0x63d7('0x1f')](respondWithResult(_0x5c623c,null))[_0x63d7('0x2a')](handleError(_0x5c623c,null));};exports[_0x63d7('0xa8')]=function(_0x56dfe0,_0x2caf82,_0x152cbc){var _0x34c6cd={'raw':![],'where':{}};var _0x70c143={};var _0x72a64c={'count':0x0,'rows':[]};return db['OpenchannelAccount'][_0x63d7('0x69')]({'where':{'id':_0x56dfe0[_0x63d7('0x58')]['id']}})[_0x63d7('0x1f')](handleEntityNotFound(_0x2caf82,null))[_0x63d7('0x1f')](function(_0x500054){if(_0x500054){_0x70c143['model']=_[_0x63d7('0x43')](db['OpenchannelInteraction'][_0x63d7('0x3e')]);_0x70c143[_0x63d7('0x42')]=_[_0x63d7('0x43')](_0x56dfe0[_0x63d7('0x42')]);_0x70c143[_0x63d7('0x4e')]=_['intersection'](_0x70c143['model'],_0x70c143[_0x63d7('0x42')]);_0x34c6cd[_0x63d7('0x44')]=_[_0x63d7('0x45')](_0x70c143[_0x63d7('0x41')],qs[_0x63d7('0x46')](_0x56dfe0['query'][_0x63d7('0x46')]));_0x34c6cd[_0x63d7('0x44')]=_0x34c6cd[_0x63d7('0x44')][_0x63d7('0x47')]?_0x34c6cd[_0x63d7('0x44')]:_0x70c143[_0x63d7('0x41')];if(!_0x56dfe0[_0x63d7('0x42')][_0x63d7('0x48')]('nolimit')){_0x34c6cd[_0x63d7('0x4a')]=qs['limit'](_0x56dfe0[_0x63d7('0x42')][_0x63d7('0x4a')]);_0x34c6cd[_0x63d7('0x2f')]=qs[_0x63d7('0x2f')](_0x56dfe0[_0x63d7('0x42')][_0x63d7('0x2f')]);}_0x34c6cd[_0x63d7('0x4b')]=qs[_0x63d7('0x4c')](_0x56dfe0['query'][_0x63d7('0x4c')]);_0x34c6cd[_0x63d7('0x4d')]=qs[_0x63d7('0x4e')](_['pick'](_0x56dfe0['query'],_0x70c143[_0x63d7('0x4e')]));_0x34c6cd[_0x63d7('0x4d')][_0x63d7('0xa4')]=_0x500054['id'];if(_0x56dfe0[_0x63d7('0x42')]['filter']){_0x34c6cd[_0x63d7('0x4d')]=_[_0x63d7('0x50')](_0x34c6cd[_0x63d7('0x4d')],{'$or':_[_0x63d7('0x3c')](_0x34c6cd[_0x63d7('0x44')],function(_0x569700){var _0x32a38d={};_0x32a38d[_0x569700]={'$like':'%'+_0x56dfe0['query']['filter']+'%'};return _0x32a38d;})});}_0x34c6cd=_['merge']({},_0x34c6cd,_0x56dfe0['options']);return db[_0x63d7('0x8e')][_0x63d7('0x52')]({'where':_0x34c6cd[_0x63d7('0x4d')]})[_0x63d7('0x1f')](function(_0x26d088){_0x72a64c['count']=_0x26d088;if(_0x56dfe0['query'][_0x63d7('0x53')]){_0x34c6cd['include']=[{'model':db[_0x63d7('0x8a')],'as':_0x63d7('0xa9'),'required':![]},{'model':db[_0x63d7('0xaa')],'as':'Owner','attributes':['name',_0x63d7('0xab'),'internal'],'required':![]},{'model':db['Tag'],'as':_0x63d7('0xac'),'attributes':['id','name',_0x63d7('0xad')],'where':_0x56dfe0[_0x63d7('0x42')][_0x63d7('0xae')]?{'id':_0x56dfe0[_0x63d7('0x42')][_0x63d7('0xae')]}:undefined,'required':_0x56dfe0[_0x63d7('0x42')][_0x63d7('0xae')]?!![]:![]}];}return db[_0x63d7('0x8e')][_0x63d7('0x55')](_0x34c6cd);})[_0x63d7('0x1f')](function(_0x1508ab){_0x72a64c['rows']=_0x1508ab;return _0x72a64c;});}})['then'](respondWithFilteredResult(_0x2caf82,_0x34c6cd))[_0x63d7('0x2a')](handleError(_0x2caf82,null));};exports[_0x63d7('0xaf')]=function(_0x13e0e6,_0x298366,_0xa222f1){return db[_0x63d7('0x3d')]['find']({'where':{'id':_0x13e0e6['params']['id']}})['then'](handleEntityNotFound(_0x298366,null))[_0x63d7('0x1f')](function(_0x148794){if(_0x148794){return _0x148794[_0x63d7('0xaf')](_0x13e0e6[_0x63d7('0x64')]['ids'],_['omit'](_0x13e0e6[_0x63d7('0x64')],['ids','id'])||{})['spread'](function(_0x15a3c7){for(var _0x93adb4=0x0;_0x93adb4<_0x13e0e6[_0x63d7('0x64')][_0x63d7('0x6e')]['length'];_0x93adb4+=0x1){socket[_0x63d7('0xb0')]('userOpenchannelAccount:save',{'UserId':_0x13e0e6[_0x63d7('0x64')][_0x63d7('0x6e')][_0x93adb4],'OpenchannelAccountId':_0x13e0e6[_0x63d7('0x58')]['id']});}return _0x15a3c7;});}})[_0x63d7('0x1f')](respondWithResult(_0x298366,null))[_0x63d7('0x2a')](handleError(_0x298366,null));};exports[_0x63d7('0xb1')]=function(_0x1285e8,_0x1b108c,_0x5da0cd){return db[_0x63d7('0x3d')]['find']({'where':{'id':_0x1285e8[_0x63d7('0x58')]['id']}})[_0x63d7('0x1f')](handleEntityNotFound(_0x1b108c,null))[_0x63d7('0x1f')](function(_0x522229){if(_0x522229){return _0x522229[_0x63d7('0xb1')](_0x1285e8[_0x63d7('0x42')]['ids'])[_0x63d7('0x1f')](function(){if(_[_0x63d7('0xb2')](_0x1285e8[_0x63d7('0x42')][_0x63d7('0x6e')])){for(var _0xc266bf=0x0;_0xc266bf<_0x1285e8[_0x63d7('0x42')]['ids'][_0x63d7('0x47')];_0xc266bf+=0x1){socket[_0x63d7('0xb0')](_0x63d7('0xb3'),{'UserId':Number(_0x1285e8['query']['ids'][_0xc266bf]),'OpenchannelAccountId':Number(_0x1285e8[_0x63d7('0x58')]['id'])});}}else{socket[_0x63d7('0xb0')]('userOpenchannelAccount:remove',{'UserId':Number(_0x1285e8[_0x63d7('0x42')][_0x63d7('0x6e')]),'OpenchannelAccountId':Number(_0x1285e8['params']['id'])});}});}})['then'](respondWithStatusCode(_0x1b108c,null))[_0x63d7('0x2a')](handleError(_0x1b108c,null));};exports[_0x63d7('0xb4')]=function(_0x7908ff,_0x5d42e0,_0x453993){var _0x3d3cd5={};var _0x43adec={};var _0x2a1ff3;var _0x3d549e;return db[_0x63d7('0x3d')][_0x63d7('0x69')]({'where':{'id':_0x7908ff[_0x63d7('0x58')]['id']}})['then'](handleEntityNotFound(_0x5d42e0,null))['then'](function(_0x338423){if(_0x338423){_0x2a1ff3=_0x338423;_0x43adec[_0x63d7('0x41')]=_[_0x63d7('0x43')](db[_0x63d7('0xaa')][_0x63d7('0x3e')]);_0x43adec['query']=_[_0x63d7('0x43')](_0x7908ff[_0x63d7('0x42')]);_0x43adec['filters']=_[_0x63d7('0x45')](_0x43adec[_0x63d7('0x41')],_0x43adec[_0x63d7('0x42')]);_0x3d3cd5[_0x63d7('0x44')]=_['intersection'](_0x43adec['model'],qs[_0x63d7('0x46')](_0x7908ff[_0x63d7('0x42')]['fields']));_0x3d3cd5[_0x63d7('0x44')]=_0x3d3cd5[_0x63d7('0x44')][_0x63d7('0x47')]?_0x3d3cd5[_0x63d7('0x44')]:_0x43adec['model'];_0x3d3cd5[_0x63d7('0x4b')]=qs[_0x63d7('0x4c')](_0x7908ff['query']['sort']);_0x3d3cd5[_0x63d7('0x4d')]=qs[_0x63d7('0x4e')](_['pick'](_0x7908ff[_0x63d7('0x42')],_0x43adec[_0x63d7('0x4e')]));if(_0x7908ff[_0x63d7('0x42')][_0x63d7('0x51')]){_0x3d3cd5[_0x63d7('0x4d')]=_[_0x63d7('0x50')](_0x3d3cd5['where'],{'$or':_[_0x63d7('0x3c')](_0x3d3cd5[_0x63d7('0x44')],function(_0x1875d0){var _0x3a2d70={};_0x3a2d70[_0x1875d0]={'$like':'%'+_0x7908ff[_0x63d7('0x42')][_0x63d7('0x51')]+'%'};return _0x3a2d70;})});}_0x3d3cd5=_[_0x63d7('0x50')]({},_0x3d3cd5,_0x7908ff[_0x63d7('0x59')]);return _0x2a1ff3[_0x63d7('0xb4')](_0x3d3cd5);}})['then'](function(_0x2c8047){if(_0x2c8047){_0x3d549e=_0x2c8047[_0x63d7('0x47')];if(!_0x7908ff[_0x63d7('0x42')][_0x63d7('0x48')](_0x63d7('0x49'))){_0x3d3cd5[_0x63d7('0x4a')]=qs[_0x63d7('0x4a')](_0x7908ff['query'][_0x63d7('0x4a')]);_0x3d3cd5[_0x63d7('0x2f')]=qs[_0x63d7('0x2f')](_0x7908ff[_0x63d7('0x42')][_0x63d7('0x2f')]);}return _0x2a1ff3['getAgents'](_0x3d3cd5);}})[_0x63d7('0x1f')](function(_0x2eacd5){if(_0x2eacd5){return _0x2eacd5?{'count':_0x3d549e,'rows':_0x2eacd5}:null;}})[_0x63d7('0x1f')](respondWithResult(_0x5d42e0,null))[_0x63d7('0x2a')](handleError(_0x5d42e0,null));};exports[_0x63d7('0x39')]=function(_0x2155e1,_0x50f944,_0x6c277a){var _0x48707b,_0x2ba960,_0x1de516;if(_[_0x63d7('0x74')](_0x2155e1[_0x63d7('0x64')]['body'])||_0x2155e1[_0x63d7('0x64')][_0x63d7('0x64')]===''){throw new db['Sequelize'][(_0x63d7('0x76'))](_0x63d7('0x78'));}if(_['isNil'](_0x2155e1[_0x63d7('0x64')]['to'])){}_0x48707b=_0x2155e1['body']['to'];return db[_0x63d7('0x3d')][_0x63d7('0x69')]({'where':{'id':_0x2155e1[_0x63d7('0x58')]['id']}})[_0x63d7('0x1f')](handleEntityNotFound(_0x50f944,null))[_0x63d7('0x1f')](function(_0x535984){if(_0x535984){return db['OpenchannelAccount']['find']({'where':{'id':_0x535984['id']},'include':[{'model':db['CmList'],'as':_0x63d7('0x7e'),'include':[{'model':db[_0x63d7('0x8a')],'as':_0x63d7('0x7f'),'where':{[_0x535984[_0x63d7('0x79')]]:_0x48707b},'limit':0x1,'order':[[_0x63d7('0x80'),_0x63d7('0x81')]]}]}]})['then'](handleEntityNotFound(_0x50f944,null))[_0x63d7('0x1f')](function(_0x3b267f){if(_0x3b267f&&_0x3b267f[_0x63d7('0x7e')]){_0x2ba960=_0x3b267f[_0x63d7('0x5c')]({'plain':!![]});if(_0x2ba960[_0x63d7('0x7e')]&&_0x2ba960[_0x63d7('0x7e')][_0x63d7('0x7f')][_0x63d7('0x47')]){return _0x2ba960['List'][_0x63d7('0x7f')][0x0];}return db['CmContact'][_0x63d7('0x5a')](_[_0x63d7('0x16')](_0x2155e1[_0x63d7('0x64')],{'firstName':_0x48707b,[_0x3b267f[_0x63d7('0x79')]]:_0x48707b,'phone':_0x48707b,'ListId':_0x2ba960[_0x63d7('0x89')]}));}})[_0x63d7('0x1f')](handleEntityNotFound(_0x50f944,null))['then'](function(_0x5b395b){if(_0x5b395b){_0x1de516=_0x5b395b;return db[_0x63d7('0x8e')][_0x63d7('0x5f')]({'where':{'ContactId':_0x1de516['id'],'closed':![],'OpenchannelAccountId':_0x2ba960['id']}})[_0x63d7('0x1f')](function(_0x5f4579){if(_0x5f4579){return[_0x5f4579,![]];}return db[_0x63d7('0x8e')][_0x63d7('0x5a')]({'UserId':_0x2155e1[_0x63d7('0x5b')]['id'],'ContactId':_0x1de516['id'],'OpenchannelAccountId':_0x2ba960['id'],'lastMsgDirection':_0x63d7('0xb5'),'Messages':[_['merge'](_0x2155e1[_0x63d7('0x64')],{'read':![],'body':_0x2155e1[_0x63d7('0x64')]['body'],'OpenchannelAccountId':_0x2ba960['id'],'UserId':_0x2155e1['user']['id'],'ContactId':_0x1de516['id']})]},{'include':[{'model':db[_0x63d7('0x98')],'as':'Messages'}]})[_0x63d7('0x1f')](function(_0x21fbb1){return[_0x21fbb1,!![]];});});}})[_0x63d7('0x90')](function(_0x15a250,_0x1dd6e1){if(_0x1dd6e1){return _0x15a250;}return db[_0x63d7('0x98')][_0x63d7('0x5a')](_['merge'](_0x2155e1[_0x63d7('0x64')],{'read':![],'body':_0x2155e1[_0x63d7('0x64')][_0x63d7('0x64')],'OpenchannelAccountId':_0x2ba960['id'],'OpenchannelInteractionId':_0x15a250['id'],'UserId':_0x2155e1[_0x63d7('0x5b')]['id'],'ContactId':_0x1de516['id']}))[_0x63d7('0x1f')](function(_0xc43278){_0x15a250[_0x63d7('0xb6')]['Messages']=[];_0x15a250[_0x63d7('0xb6')]['Messages']['push'](_0xc43278[_0x63d7('0xb6')]);return _0x15a250;});});}})[_0x63d7('0x1f')](respondWithResult(_0x50f944,null))[_0x63d7('0x2a')](handleError(_0x50f944,null));};
\ No newline at end of file
+var _0xb6db=['OpenchannelApplication','Applications','account','applications','list','contact','firstName','lastName','threadId','OpenchannelInteraction','externalUrl','spread','messageId','interaction','created','autoclose','push','close','unmanaged','*,*,*,*','OpenchannelMessage','AttachmentId','UserId','User','unshift','agent','forcedOwnership','Start','startRouting','EventManager','addApplications','sequelize','transaction','bulkCreate','findAndCountAll','getApplications','getInteractions','Owner','internal','Tag','Tags','tag','addAgents','omit','emit','removeAgents','userOpenchannelAccount:remove','getAgents','send','body\x20is\x20mandatory\x20and\x20not\x20empty','Messages','dataValues','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./openchannelAccount.socket','client','http','request','then','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','save','update','destroy','get','OpenchannelAccounts','UserProfileResource','stack','name','index','mandatoryDispositionPause','rawAttributes','fieldName','type','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','merge','VIRTUAL','filter','options','OpenchannelAccount','include','findAll','show','Pause','includeAll','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','OpenchannelAccountId','Disposition','getDispositions','findOne','nolimit','rows','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','notify','openchannel','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','isNil','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC'];(function(_0x46f659,_0x524ad6){var _0x26ec03=function(_0x157447){while(--_0x157447){_0x46f659['push'](_0x46f659['shift']());}};_0x26ec03(++_0x524ad6);}(_0xb6db,0xec));var _0xbb6d=function(_0x3f4c89,_0x2e3930){_0x3f4c89=_0x3f4c89-0x0;var _0x5591bd=_0xb6db[_0x3f4c89];return _0x5591bd;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xbb6d('0x0'));var rimraf=require(_0xbb6d('0x1'));var zipdir=require(_0xbb6d('0x2'));var jsonpatch=require(_0xbb6d('0x3'));var rp=require(_0xbb6d('0x4'));var moment=require(_0xbb6d('0x5'));var BPromise=require(_0xbb6d('0x6'));var Mustache=require(_0xbb6d('0x7'));var util=require('util');var path=require(_0xbb6d('0x8'));var sox=require('sox');var csv=require(_0xbb6d('0x9'));var ejs=require(_0xbb6d('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0xbb6d('0xb'));var crypto=require(_0xbb6d('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xbb6d('0x9'));var querystring=require(_0xbb6d('0xd'));var Papa=require(_0xbb6d('0xe'));var Redis=require(_0xbb6d('0xf'));var authService=require(_0xbb6d('0x10'));var qs=require(_0xbb6d('0x11'));var as=require(_0xbb6d('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xbb6d('0x13'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xbb6d('0x14'))['db'];config['redis']=_[_0xbb6d('0x15')](config[_0xbb6d('0x16')],{'host':_0xbb6d('0x17'),'port':0x18eb});var socket=require(_0xbb6d('0x18'))(new Redis(config['redis']));require(_0xbb6d('0x19'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0xbb6d('0x1a')][_0xbb6d('0x1b')]({'port':0x232c});var client9002=jayson[_0xbb6d('0x1a')][_0xbb6d('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x19b0c1,_0x4d992b,_0x531e64,_0x555a99){return new BPromise(function(_0x2ab467,_0x432627){var _0x36610b=_0x555a99||client;return _0x36610b[_0xbb6d('0x1c')](_0x19b0c1,_0x531e64)[_0xbb6d('0x1d')](function(_0x4159c2){logger['info'](_0xbb6d('0x1e'),_0x4d992b,_0xbb6d('0x1f'));logger[_0xbb6d('0x20')](_0xbb6d('0x21'),_0x4d992b,_0xbb6d('0x1f'),JSON[_0xbb6d('0x22')](_0x4159c2));if(_0x4159c2[_0xbb6d('0x23')]){if(_0x4159c2['error'][_0xbb6d('0x24')]===0x1f4){logger[_0xbb6d('0x23')](_0xbb6d('0x1e'),_0x4d992b,_0x4159c2[_0xbb6d('0x23')]['message']);return _0x432627(_0x4159c2[_0xbb6d('0x23')][_0xbb6d('0x25')]);}logger[_0xbb6d('0x23')](_0xbb6d('0x1e'),_0x4d992b,_0x4159c2[_0xbb6d('0x23')][_0xbb6d('0x25')]);return _0x2ab467(_0x4159c2['error']['message']);}else{logger[_0xbb6d('0x26')](_0xbb6d('0x1e'),_0x4d992b,_0xbb6d('0x1f'));_0x2ab467(_0x4159c2[_0xbb6d('0x27')][_0xbb6d('0x25')]);}})[_0xbb6d('0x28')](function(_0x146f71){logger[_0xbb6d('0x23')]('OpenchannelAccount,\x20%s,\x20%s',_0x4d992b,_0x146f71);_0x432627(_0x146f71);});});}function respondWithStatusCode(_0x11aaa4,_0xf9dd48){_0xf9dd48=_0xf9dd48||0xcc;return function(_0x13f6c2){if(_0x13f6c2){return _0x11aaa4[_0xbb6d('0x29')](_0xf9dd48);}return _0x11aaa4[_0xbb6d('0x2a')](_0xf9dd48)[_0xbb6d('0x2b')]();};}function respondWithResult(_0x286702,_0x2b49c4){_0x2b49c4=_0x2b49c4||0xc8;return function(_0x1cac5e){if(_0x1cac5e){return _0x286702[_0xbb6d('0x2a')](_0x2b49c4)[_0xbb6d('0x2c')](_0x1cac5e);}};}function respondWithFilteredResult(_0x86e4cb,_0x32765e){return function(_0x5e9f21){if(_0x5e9f21){var _0x3c8741=_0x5e9f21[_0xbb6d('0x2d')],_0x39e582=_0x32765e['offset'],_0x6953ac=_0x32765e[_0xbb6d('0x2e')]+_0x32765e[_0xbb6d('0x2f')],_0x23b1c2;if(_0x6953ac>=_0x3c8741){_0x6953ac=_0x3c8741;_0x23b1c2=0xc8;}else{_0x23b1c2=0xce;}_0x86e4cb[_0xbb6d('0x2a')](_0x23b1c2);return _0x86e4cb['set'](_0xbb6d('0x30'),_0x39e582+'-'+_0x6953ac+'/'+_0x3c8741)['json'](_0x5e9f21);}return null;};}function patchUpdates(_0x1977cf){return function(_0x2e6709){try{jsonpatch[_0xbb6d('0x31')](_0x2e6709,_0x1977cf,!![]);}catch(_0x43ed9){return BPromise['reject'](_0x43ed9);}return _0x2e6709[_0xbb6d('0x32')]();};}function saveUpdates(_0x1fc820,_0x3f60d8){return function(_0x4afed4){if(_0x4afed4){return _0x4afed4[_0xbb6d('0x33')](_0x1fc820)[_0xbb6d('0x1d')](function(_0x1c404a){return _0x1c404a;});}return null;};}function removeEntity(_0x28dbb6,_0x267e52){return function(_0x443680){if(_0x443680){return _0x443680[_0xbb6d('0x34')]()[_0xbb6d('0x1d')](function(){var _0x56527b=_0x443680[_0xbb6d('0x35')]({'plain':!![]});var _0x392dba=_0xbb6d('0x36');return db[_0xbb6d('0x37')][_0xbb6d('0x34')]({'where':{'type':_0x392dba,'resourceId':_0x56527b['id']}})[_0xbb6d('0x1d')](function(){return _0x443680;});})[_0xbb6d('0x1d')](function(){_0x28dbb6[_0xbb6d('0x2a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x22c9f5,_0x10ce0b){return function(_0x6062b4){if(!_0x6062b4){_0x22c9f5['sendStatus'](0x194);}return _0x6062b4;};}function handleError(_0xcf4d30,_0x2d20d8){_0x2d20d8=_0x2d20d8||0x1f4;return function(_0x54873e){logger[_0xbb6d('0x23')](_0x54873e[_0xbb6d('0x38')]);if(_0x54873e[_0xbb6d('0x39')]){delete _0x54873e[_0xbb6d('0x39')];}_0xcf4d30[_0xbb6d('0x2a')](_0x2d20d8)['send'](_0x54873e);};}exports[_0xbb6d('0x3a')]=function(_0x2da9be,_0x27f1a2){var _0x1b8cb1={'include':[{'model':db['Pause'],'as':_0xbb6d('0x3b')}]},_0x3d9439={},_0x3620c9={'count':0x0,'rows':[]};var _0x52ec3d=_['map'](db['OpenchannelAccount'][_0xbb6d('0x3c')],function(_0xfef523){return{'name':_0xfef523[_0xbb6d('0x3d')],'type':_0xfef523[_0xbb6d('0x3e')]['key']};});_0x3d9439[_0xbb6d('0x3f')]=_[_0xbb6d('0x40')](_0x52ec3d,_0xbb6d('0x39'));_0x3d9439[_0xbb6d('0x41')]=_[_0xbb6d('0x42')](_0x2da9be[_0xbb6d('0x41')]);_0x3d9439[_0xbb6d('0x43')]=_[_0xbb6d('0x44')](_0x3d9439[_0xbb6d('0x3f')],_0x3d9439[_0xbb6d('0x41')]);_0x1b8cb1[_0xbb6d('0x45')]=_['intersection'](_0x3d9439[_0xbb6d('0x3f')],qs[_0xbb6d('0x46')](_0x2da9be[_0xbb6d('0x41')]['fields']));_0x1b8cb1[_0xbb6d('0x45')]=_0x1b8cb1['attributes'][_0xbb6d('0x47')]?_0x1b8cb1['attributes']:_0x3d9439[_0xbb6d('0x3f')];if(!_0x2da9be[_0xbb6d('0x41')][_0xbb6d('0x48')]('nolimit')){_0x1b8cb1['limit']=qs[_0xbb6d('0x2f')](_0x2da9be['query'][_0xbb6d('0x2f')]);_0x1b8cb1['offset']=qs['offset'](_0x2da9be[_0xbb6d('0x41')][_0xbb6d('0x2e')]);}_0x1b8cb1[_0xbb6d('0x49')]=qs['sort'](_0x2da9be[_0xbb6d('0x41')][_0xbb6d('0x4a')]);_0x1b8cb1[_0xbb6d('0x4b')]=qs[_0xbb6d('0x43')](_[_0xbb6d('0x4c')](_0x2da9be[_0xbb6d('0x41')],_0x3d9439[_0xbb6d('0x43')]),_0x52ec3d);if(_0x2da9be[_0xbb6d('0x41')]['filter']){_0x1b8cb1[_0xbb6d('0x4b')]=_[_0xbb6d('0x4d')](_0x1b8cb1['where'],{'$or':_[_0xbb6d('0x40')](_0x52ec3d,function(_0x41c9a2){if(_0x41c9a2[_0xbb6d('0x3e')]!==_0xbb6d('0x4e')){var _0x2e9ea9={};_0x2e9ea9[_0x41c9a2['name']]={'$like':'%'+_0x2da9be[_0xbb6d('0x41')][_0xbb6d('0x4f')]+'%'};return _0x2e9ea9;}})});}_0x1b8cb1=_['merge']({},_0x1b8cb1,_0x2da9be[_0xbb6d('0x50')]);var _0x3bcc49={'where':_0x1b8cb1['where']};return db[_0xbb6d('0x51')][_0xbb6d('0x2d')](_0x3bcc49)[_0xbb6d('0x1d')](function(_0x4e4111){_0x3620c9[_0xbb6d('0x2d')]=_0x4e4111;if(_0x2da9be[_0xbb6d('0x41')]['includeAll']){_0x1b8cb1[_0xbb6d('0x52')]=[{'all':!![]}];}return db[_0xbb6d('0x51')][_0xbb6d('0x53')](_0x1b8cb1);})[_0xbb6d('0x1d')](function(_0x5a841b){_0x3620c9['rows']=_0x5a841b;return _0x3620c9;})[_0xbb6d('0x1d')](respondWithFilteredResult(_0x27f1a2,_0x1b8cb1))[_0xbb6d('0x28')](handleError(_0x27f1a2,null));};exports[_0xbb6d('0x54')]=function(_0x350f69,_0x211829){var _0xbf62a8={'raw':![],'where':{'id':_0x350f69['params']['id']},'include':[{'model':db[_0xbb6d('0x55')],'as':_0xbb6d('0x3b')}]},_0x5d4093={};_0x5d4093['model']=_[_0xbb6d('0x42')](db[_0xbb6d('0x51')][_0xbb6d('0x3c')]);_0x5d4093[_0xbb6d('0x41')]=_['keys'](_0x350f69[_0xbb6d('0x41')]);_0x5d4093[_0xbb6d('0x43')]=_['intersection'](_0x5d4093[_0xbb6d('0x3f')],_0x5d4093[_0xbb6d('0x41')]);_0xbf62a8[_0xbb6d('0x45')]=_[_0xbb6d('0x44')](_0x5d4093[_0xbb6d('0x3f')],qs[_0xbb6d('0x46')](_0x350f69[_0xbb6d('0x41')][_0xbb6d('0x46')]));_0xbf62a8[_0xbb6d('0x45')]=_0xbf62a8[_0xbb6d('0x45')][_0xbb6d('0x47')]?_0xbf62a8[_0xbb6d('0x45')]:_0x5d4093['model'];if(_0x350f69[_0xbb6d('0x41')][_0xbb6d('0x56')]){_0xbf62a8[_0xbb6d('0x52')]=[{'all':!![]}];}_0xbf62a8=_['merge']({},_0xbf62a8,_0x350f69[_0xbb6d('0x50')]);return db[_0xbb6d('0x51')]['find'](_0xbf62a8)[_0xbb6d('0x1d')](handleEntityNotFound(_0x211829,null))[_0xbb6d('0x1d')](respondWithResult(_0x211829,null))[_0xbb6d('0x28')](handleError(_0x211829,null));};exports['create']=function(_0x3679a2,_0x373dea){return db[_0xbb6d('0x51')][_0xbb6d('0x57')](_0x3679a2[_0xbb6d('0x58')],{})['then'](function(_0x5c1f0f){var _0x4591d2=_0x3679a2[_0xbb6d('0x59')][_0xbb6d('0x35')]({'plain':!![]});if(!_0x4591d2)throw new Error(_0xbb6d('0x5a'));if(_0x4591d2[_0xbb6d('0x5b')]===_0xbb6d('0x59')){var _0x143f97=_0x5c1f0f[_0xbb6d('0x35')]({'plain':!![]});var _0x32cba8='OpenchannelAccounts';return db['UserProfileSection'][_0xbb6d('0x5c')]({'where':{'name':_0x32cba8,'userProfileId':_0x4591d2[_0xbb6d('0x5d')]},'raw':!![]})['then'](function(_0x3519bd){if(_0x3519bd&&_0x3519bd[_0xbb6d('0x5e')]===0x0){return db['UserProfileResource'][_0xbb6d('0x57')]({'name':_0x143f97[_0xbb6d('0x39')],'resourceId':_0x143f97['id'],'type':_0x3519bd[_0xbb6d('0x39')],'sectionId':_0x3519bd['id']},{})[_0xbb6d('0x1d')](function(){return _0x5c1f0f;});}else{return _0x5c1f0f;}})[_0xbb6d('0x28')](function(_0x24b82a){logger[_0xbb6d('0x23')](_0xbb6d('0x5f'),_0x24b82a);throw _0x24b82a;});}return _0x5c1f0f;})[_0xbb6d('0x1d')](respondWithResult(_0x373dea,0xc9))[_0xbb6d('0x28')](handleError(_0x373dea,null));};exports[_0xbb6d('0x33')]=function(_0x50154d,_0x2e8520){if(_0x50154d['body']['id']){delete _0x50154d['body']['id'];}return db[_0xbb6d('0x51')]['find']({'where':{'id':_0x50154d[_0xbb6d('0x60')]['id']},'include':[{'model':db[_0xbb6d('0x55')],'as':_0xbb6d('0x3b')}]})[_0xbb6d('0x1d')](handleEntityNotFound(_0x2e8520,null))[_0xbb6d('0x1d')](saveUpdates(_0x50154d[_0xbb6d('0x58')],null))[_0xbb6d('0x1d')](respondWithResult(_0x2e8520,null))[_0xbb6d('0x28')](handleError(_0x2e8520,null));};exports['destroy']=function(_0x5ab958,_0x151f16){return db[_0xbb6d('0x51')][_0xbb6d('0x5c')]({'where':{'id':_0x5ab958['params']['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x151f16,null))[_0xbb6d('0x1d')](removeEntity(_0x151f16,null))[_0xbb6d('0x28')](handleError(_0x151f16,null));};exports['describe']=function(_0x493337,_0x2367d6){return db['OpenchannelAccount'][_0xbb6d('0x61')]()[_0xbb6d('0x1d')](respondWithResult(_0x2367d6,null))[_0xbb6d('0x28')](handleError(_0x2367d6,null));};exports[_0xbb6d('0x62')]=function(_0x324a75,_0x18860f,_0x4e8776){if(_0x324a75[_0xbb6d('0x58')]['id']){delete _0x324a75[_0xbb6d('0x58')]['id'];}return db[_0xbb6d('0x51')][_0xbb6d('0x5c')]({'where':{'id':_0x324a75[_0xbb6d('0x60')]['id']}})['then'](handleEntityNotFound(_0x18860f,null))[_0xbb6d('0x1d')](function(_0x213045){if(_0x213045){_0x324a75[_0xbb6d('0x58')][_0xbb6d('0x63')]=_0x213045['id'];return db[_0xbb6d('0x64')][_0xbb6d('0x57')](_0x324a75[_0xbb6d('0x58')]);}})['then'](respondWithResult(_0x18860f,null))['catch'](handleError(_0x18860f,null));};exports[_0xbb6d('0x65')]=function(_0x39f41a,_0x93539,_0x2148a1){var _0x33bb0a={'raw':![],'where':{}};var _0x3dd837={};var _0x1c3b56={'count':0x0,'rows':[]};return db['OpenchannelAccount'][_0xbb6d('0x66')]({'where':{'id':_0x39f41a[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x93539,null))['then'](function(_0x35b3b6){if(_0x35b3b6){_0x3dd837[_0xbb6d('0x3f')]=_['keys'](db[_0xbb6d('0x64')]['rawAttributes']);_0x3dd837[_0xbb6d('0x41')]=_[_0xbb6d('0x42')](_0x39f41a[_0xbb6d('0x41')]);_0x3dd837['filters']=_[_0xbb6d('0x44')](_0x3dd837['model'],_0x3dd837[_0xbb6d('0x41')]);_0x33bb0a[_0xbb6d('0x45')]=_[_0xbb6d('0x44')](_0x3dd837[_0xbb6d('0x3f')],qs[_0xbb6d('0x46')](_0x39f41a[_0xbb6d('0x41')][_0xbb6d('0x46')]));_0x33bb0a[_0xbb6d('0x45')]=_0x33bb0a['attributes']['length']?_0x33bb0a['attributes']:_0x3dd837[_0xbb6d('0x3f')];if(!_0x39f41a['query']['hasOwnProperty'](_0xbb6d('0x67'))){_0x33bb0a[_0xbb6d('0x2f')]=qs[_0xbb6d('0x2f')](_0x39f41a['query'][_0xbb6d('0x2f')]);_0x33bb0a['offset']=qs[_0xbb6d('0x2e')](_0x39f41a[_0xbb6d('0x41')][_0xbb6d('0x2e')]);}_0x33bb0a[_0xbb6d('0x49')]=qs[_0xbb6d('0x4a')](_0x39f41a['query'][_0xbb6d('0x4a')]);_0x33bb0a[_0xbb6d('0x4b')]=qs[_0xbb6d('0x43')](_[_0xbb6d('0x4c')](_0x39f41a['query'],_0x3dd837[_0xbb6d('0x43')]));_0x33bb0a['where'][_0xbb6d('0x63')]=_0x35b3b6['id'];if(_0x39f41a[_0xbb6d('0x41')][_0xbb6d('0x4f')]){_0x33bb0a[_0xbb6d('0x4b')]=_[_0xbb6d('0x4d')](_0x33bb0a[_0xbb6d('0x4b')],{'$or':_[_0xbb6d('0x40')](_0x33bb0a[_0xbb6d('0x45')],function(_0x55515b){var _0x2a64d8={};_0x2a64d8[_0x55515b]={'$like':'%'+_0x39f41a[_0xbb6d('0x41')][_0xbb6d('0x4f')]+'%'};return _0x2a64d8;})});}_0x33bb0a=_['merge']({},_0x33bb0a,_0x39f41a[_0xbb6d('0x50')]);return db[_0xbb6d('0x64')][_0xbb6d('0x2d')]({'where':_0x33bb0a[_0xbb6d('0x4b')]})['then'](function(_0x54255f){_0x1c3b56[_0xbb6d('0x2d')]=_0x54255f;if(_0x39f41a[_0xbb6d('0x41')]['includeAll']){_0x33bb0a[_0xbb6d('0x52')]=[{'all':!![]}];}return db[_0xbb6d('0x64')]['findAll'](_0x33bb0a);})['then'](function(_0x4e30cc){_0x1c3b56[_0xbb6d('0x68')]=_0x4e30cc;return _0x1c3b56;});}})[_0xbb6d('0x1d')](respondWithFilteredResult(_0x93539,_0x33bb0a))['catch'](handleError(_0x93539,null));};exports[_0xbb6d('0x69')]=function(_0x4e4555,_0x29f40e,_0x3e5ce8){return db[_0xbb6d('0x51')]['find']({'where':{'id':_0x4e4555[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x29f40e,null))[_0xbb6d('0x1d')](function(_0x230f7f){if(_0x230f7f){return _0x230f7f[_0xbb6d('0x69')](_0x4e4555[_0xbb6d('0x41')][_0xbb6d('0x6a')]);}})[_0xbb6d('0x1d')](respondWithStatusCode(_0x29f40e,null))[_0xbb6d('0x28')](handleError(_0x29f40e,null));};exports[_0xbb6d('0x6b')]=function(_0x3b771b,_0x20e637,_0x396be2){if(_0x3b771b['body']['id']){delete _0x3b771b[_0xbb6d('0x58')]['id'];}return db[_0xbb6d('0x51')][_0xbb6d('0x5c')]({'where':{'id':_0x3b771b[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x20e637,null))[_0xbb6d('0x1d')](function(_0x350ce1){if(_0x350ce1){_0x3b771b[_0xbb6d('0x58')][_0xbb6d('0x63')]=_0x350ce1['id'];return db[_0xbb6d('0x6c')]['create'](_0x3b771b['body']);}})['then'](respondWithResult(_0x20e637,null))[_0xbb6d('0x28')](handleError(_0x20e637,null));};exports[_0xbb6d('0x6d')]=function(_0x224943,_0x13a5cd,_0x4a7fbc){var _0x3e15b4={'raw':![],'where':{}};var _0x115f3={};var _0x56f625={'count':0x0,'rows':[]};return db[_0xbb6d('0x51')][_0xbb6d('0x66')]({'where':{'id':_0x224943[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x13a5cd,null))[_0xbb6d('0x1d')](function(_0xf24186){if(_0xf24186){_0x115f3[_0xbb6d('0x3f')]=_['keys'](db['CannedAnswer'][_0xbb6d('0x3c')]);_0x115f3['query']=_[_0xbb6d('0x42')](_0x224943[_0xbb6d('0x41')]);_0x115f3['filters']=_[_0xbb6d('0x44')](_0x115f3[_0xbb6d('0x3f')],_0x115f3[_0xbb6d('0x41')]);_0x3e15b4['attributes']=_['intersection'](_0x115f3[_0xbb6d('0x3f')],qs[_0xbb6d('0x46')](_0x224943[_0xbb6d('0x41')][_0xbb6d('0x46')]));_0x3e15b4['attributes']=_0x3e15b4['attributes'][_0xbb6d('0x47')]?_0x3e15b4[_0xbb6d('0x45')]:_0x115f3['model'];if(!_0x224943[_0xbb6d('0x41')]['hasOwnProperty'](_0xbb6d('0x67'))){_0x3e15b4['limit']=qs[_0xbb6d('0x2f')](_0x224943[_0xbb6d('0x41')][_0xbb6d('0x2f')]);_0x3e15b4[_0xbb6d('0x2e')]=qs[_0xbb6d('0x2e')](_0x224943[_0xbb6d('0x41')][_0xbb6d('0x2e')]);}_0x3e15b4[_0xbb6d('0x49')]=qs[_0xbb6d('0x4a')](_0x224943['query']['sort']);_0x3e15b4[_0xbb6d('0x4b')]=qs[_0xbb6d('0x43')](_[_0xbb6d('0x4c')](_0x224943[_0xbb6d('0x41')],_0x115f3[_0xbb6d('0x43')]));_0x3e15b4[_0xbb6d('0x4b')][_0xbb6d('0x63')]=_0xf24186['id'];if(_0x224943[_0xbb6d('0x41')][_0xbb6d('0x4f')]){_0x3e15b4[_0xbb6d('0x4b')]=_[_0xbb6d('0x4d')](_0x3e15b4[_0xbb6d('0x4b')],{'$or':_[_0xbb6d('0x40')](_0x3e15b4[_0xbb6d('0x45')],function(_0x3c6905){var _0x28702c={};_0x28702c[_0x3c6905]={'$like':'%'+_0x224943[_0xbb6d('0x41')]['filter']+'%'};return _0x28702c;})});}_0x3e15b4=_[_0xbb6d('0x4d')]({},_0x3e15b4,_0x224943[_0xbb6d('0x50')]);return db[_0xbb6d('0x6c')][_0xbb6d('0x2d')]({'where':_0x3e15b4[_0xbb6d('0x4b')]})[_0xbb6d('0x1d')](function(_0x3d13c1){_0x56f625[_0xbb6d('0x2d')]=_0x3d13c1;if(_0x224943[_0xbb6d('0x41')][_0xbb6d('0x56')]){_0x3e15b4[_0xbb6d('0x52')]=[{'all':!![]}];}return db['CannedAnswer'][_0xbb6d('0x53')](_0x3e15b4);})[_0xbb6d('0x1d')](function(_0x4d6809){_0x56f625[_0xbb6d('0x68')]=_0x4d6809;return _0x56f625;});}})[_0xbb6d('0x1d')](respondWithFilteredResult(_0x13a5cd,_0x3e15b4))[_0xbb6d('0x28')](handleError(_0x13a5cd,null));};exports[_0xbb6d('0x6e')]=function(_0x4383b7,_0x58b65b,_0x480eec){return db[_0xbb6d('0x51')][_0xbb6d('0x5c')]({'where':{'id':_0x4383b7[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x58b65b,null))['then'](function(_0x434db7){if(_0x434db7){return _0x434db7[_0xbb6d('0x6e')](_0x4383b7[_0xbb6d('0x41')][_0xbb6d('0x6a')]);}})[_0xbb6d('0x1d')](respondWithStatusCode(_0x58b65b,null))[_0xbb6d('0x28')](handleError(_0x58b65b,null));};exports[_0xbb6d('0x6f')]=function(_0x5115e3,_0x4bc73c,_0x13ec94){var _0x3d8b0b={'body':_0x5115e3[_0xbb6d('0x58')],'channel':_0xbb6d('0x70')};var _0x33ad6b=[];var _0x1cd642=[];var _0x2a77a7={};var _0x2ab8fc=![];return db[_0xbb6d('0x71')][_0xbb6d('0x61')]()['then'](function(_0x33e9eb){if(!_0x33e9eb){throw new db[(_0xbb6d('0x72'))][(_0xbb6d('0x73'))](_0xbb6d('0x74'));}_0x33ad6b=_[_0xbb6d('0x75')](_[_0xbb6d('0x42')](_0x33e9eb),[_0xbb6d('0x76'),'updatedAt']);_0x1cd642=_[_0xbb6d('0x75')](_['keys'](_0x33e9eb),[_0xbb6d('0x76'),_0xbb6d('0x77'),_0xbb6d('0x78'),_0xbb6d('0x79')]);if(_0x5115e3[_0xbb6d('0x58')]['id']){delete _0x5115e3[_0xbb6d('0x58')]['id'];}if(_['isNil'](_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x7a')])){throw new db[(_0xbb6d('0x72'))][(_0xbb6d('0x73'))]('from\x20is\x20mandatory');}if(_['isNil'](_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x58')])||_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x58')]===''){throw new db[(_0xbb6d('0x72'))][(_0xbb6d('0x73'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xbb6d('0x7b')](_0x5115e3['body'][_0xbb6d('0x7c')])){throw new db[(_0xbb6d('0x72'))][(_0xbb6d('0x73'))](_0xbb6d('0x7d')+_0x1cd642);}if(!_[_0xbb6d('0x7e')](_0x1cd642,_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x7c')])){throw new db['Sequelize'][(_0xbb6d('0x73'))](_0xbb6d('0x7f')+_0x1cd642);}_0x2a77a7[_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x7c')]]=_0x5115e3[_0xbb6d('0x58')]['from'];})['then'](function(){return db['OpenchannelAccount']['find']({'where':{'id':_0x5115e3[_0xbb6d('0x60')]['id']},'include':[{'model':db[_0xbb6d('0x80')],'as':_0xbb6d('0x81'),'include':[{'model':db['CmContact'],'as':_0xbb6d('0x82'),'where':_0x2a77a7,'limit':0x1,'order':[[_0xbb6d('0x77'),_0xbb6d('0x83')]]}]},{'model':db[_0xbb6d('0x84')],'as':_0xbb6d('0x85')}]});})[_0xbb6d('0x1d')](handleEntityNotFound(_0x4bc73c,null))['then'](function(_0x2a6c9d){if(_0x2a6c9d&&_0x2a6c9d[_0xbb6d('0x81')]){_0x3d8b0b[_0xbb6d('0x86')]=_0x2a6c9d;_0x3d8b0b[_0xbb6d('0x87')]=_0x2a6c9d[_0xbb6d('0x85')];_0x3d8b0b[_0xbb6d('0x88')]=_0x2a6c9d[_0xbb6d('0x81')];_0x3d8b0b[_0xbb6d('0x87')]=_['orderBy'](_0x3d8b0b[_0xbb6d('0x87')],['priority'],['asc']);if(_0x3d8b0b[_0xbb6d('0x86')]['Applications']){delete _0x3d8b0b[_0xbb6d('0x86')][_0xbb6d('0x85')];}if(_0x3d8b0b[_0xbb6d('0x86')][_0xbb6d('0x81')]&&_0x3d8b0b[_0xbb6d('0x86')]['List']['Contacts'][_0xbb6d('0x47')]){return _0x3d8b0b[_0xbb6d('0x86')][_0xbb6d('0x81')]['Contacts'][0x0];}var _0x4faf60=_['defaults'](_0x5115e3[_0xbb6d('0x58')],{'firstName':_0x5115e3['body']['from'],'ListId':_0x2a6c9d['ListId']});_0x4faf60[_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x7c')]]=_0x5115e3[_0xbb6d('0x58')]['from'];return db[_0xbb6d('0x71')][_0xbb6d('0x57')](_0x4faf60,{'fields':_0x33ad6b,'raw':!![]});}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x4bc73c,null))[_0xbb6d('0x1d')](function(_0x2e3c6e){_0x3d8b0b[_0xbb6d('0x89')]=_0x2e3c6e;if(_0x2e3c6e){var _0x913cd8={'ContactId':_0x2e3c6e['id'],'OpenchannelAccountId':_0x5115e3[_0xbb6d('0x60')]['id'],'from':(_0x2e3c6e[_0xbb6d('0x8a')]||'')+'\x20'+(_0x2e3c6e[_0xbb6d('0x8b')]||'')};var _0x3b8e20={'OpenchannelAccountId':_0x5115e3[_0xbb6d('0x60')]['id'],'closed':![]};if(_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x8c')]){_0x3b8e20[_0xbb6d('0x8c')]=_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x8c')];return db[_0xbb6d('0x8d')]['find']({'where':_0x3b8e20})[_0xbb6d('0x1d')](function(_0x166e8b){if(_0x166e8b){return[_0x166e8b,![]];}_0x913cd8[_0xbb6d('0x8c')]=_0x5115e3['body']['threadId'];_0x913cd8[_0xbb6d('0x8e')]=_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x8e')];return db['OpenchannelInteraction']['create'](_0x913cd8)['then'](function(_0x14726b){return[_0x14726b,!![]];});});}else{_0x3b8e20[_0xbb6d('0x8c')]=null;}_0x3b8e20['ContactId']=_0x2e3c6e['id'];return db[_0xbb6d('0x8d')][_0xbb6d('0x5c')]({'where':_0x3b8e20})[_0xbb6d('0x1d')](function(_0x3e6403){if(_0x3e6403){return[_0x3e6403,![]];}return db[_0xbb6d('0x8d')][_0xbb6d('0x57')](_0x913cd8)[_0xbb6d('0x1d')](function(_0x3c1553){return[_0x3c1553,!![]];});});}})[_0xbb6d('0x8f')](function(_0x537394,_0x5758c7){if(_0x537394){_0x2ab8fc=_0x5758c7;if(!_0x5758c7){var _0x45375e={'from':(_0x3d8b0b['contact'][_0xbb6d('0x8a')]||'')+'\x20'+(_0x3d8b0b[_0xbb6d('0x89')][_0xbb6d('0x8b')]||'')};if(_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x8c')]&&_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x90')]&&_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x8c')]!=_0x5115e3['body'][_0xbb6d('0x90')]){_0x45375e[_0xbb6d('0x8c')]=_0x5115e3[_0xbb6d('0x58')]['messageId'];}return _0x537394[_0xbb6d('0x33')](_0x45375e);}else{return _0x537394;}}})[_0xbb6d('0x1d')](function(_0x43999e){_0x3d8b0b[_0xbb6d('0x91')]=_0x43999e['get']({'plain':!![]});_0x3d8b0b[_0xbb6d('0x91')][_0xbb6d('0x92')]=_0x2ab8fc;if(_0x3d8b0b[_0xbb6d('0x91')][_0xbb6d('0x92')]){if(_0x3d8b0b[_0xbb6d('0x86')][_0xbb6d('0x93')]){_0x3d8b0b[_0xbb6d('0x87')][_0xbb6d('0x94')]({'id':0x0,'priority':_0x3d8b0b['applications']['length']+0x1,'app':_0xbb6d('0x95'),'appdata':_0xbb6d('0x96'),'interval':_0xbb6d('0x97')});}}return db[_0xbb6d('0x98')]['create']({'body':_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x58')],'OpenchannelAccountId':_0x5115e3['params']['id'],'OpenchannelInteractionId':_0x43999e['id'],'direction':'in','ContactId':_0x3d8b0b[_0xbb6d('0x89')]['id'],'AttachmentId':_0x5115e3[_0xbb6d('0x58')][_0xbb6d('0x99')]});})['then'](function(_0x2be16c){_0x3d8b0b[_0xbb6d('0x25')]=_0x2be16c;if(_0x3d8b0b[_0xbb6d('0x91')][_0xbb6d('0x9a')]){return db[_0xbb6d('0x9b')][_0xbb6d('0x5c')]({'attributes':['id',_0xbb6d('0x39')],'where':{'id':_0x3d8b0b[_0xbb6d('0x91')][_0xbb6d('0x9a')]}})[_0xbb6d('0x1d')](function(_0x22820c){if(_0x22820c){_0x3d8b0b[_0xbb6d('0x87')][_0xbb6d('0x9c')]({'id':0x0,'priority':0x0,'app':_0xbb6d('0x9d'),'appdata':_0x22820c[_0xbb6d('0x39')]+','+(_0x3d8b0b[_0xbb6d('0x86')]['waitForTheAssignedAgent']||0xa),'interval':'*,*,*,*'});_0x3d8b0b[_0xbb6d('0x9e')]=![];}return respondWithRpcPromise(_0xbb6d('0x9f'),_0xbb6d('0xa0'),_0x3d8b0b);});}return respondWithRpcPromise(_0xbb6d('0x9f'),'startRouting',_0x3d8b0b);})['then'](function(_0x327623){respondWithRpcPromise(_0xbb6d('0xa1'),_0xbb6d('0xa1'),{'event':_0xbb6d('0x6f'),'message':_0x327623},client9002);return _0x327623;})[_0xbb6d('0x1d')](respondWithResult(_0x4bc73c,null))[_0xbb6d('0x28')](handleError(_0x4bc73c,null));};exports[_0xbb6d('0xa2')]=function(_0x59774b,_0x476e48,_0x1d1774){return db[_0xbb6d('0x51')]['findOne']({'where':{'id':_0x59774b[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x476e48,null))['then'](function(_0x358357){if(_0x358357){return db[_0xbb6d('0xa3')][_0xbb6d('0xa4')](function(_0x4de60b){return db[_0xbb6d('0x84')][_0xbb6d('0x34')]({'where':{'OpenchannelAccountId':_0x59774b[_0xbb6d('0x60')]['id']},'transaction':_0x4de60b})['then'](function(_0x492d24){var _0x1ef849=_[_0xbb6d('0x40')](_0x59774b['body'],function(_0x57ac32){_0x57ac32[_0xbb6d('0x63')]=_0x59774b[_0xbb6d('0x60')]['id'];return _0x57ac32;});return db[_0xbb6d('0x84')][_0xbb6d('0xa5')](_0x1ef849,{'transaction':_0x4de60b});});})['then'](function(){return db[_0xbb6d('0x84')][_0xbb6d('0xa6')]({'where':{'OpenchannelAccountId':_0x59774b['params']['id']},'order':'priority'});});}})[_0xbb6d('0x1d')](respondWithResult(_0x476e48,null))['catch'](handleError(_0x476e48,null));};exports['getApplications']=function(_0x366d8b,_0x4e7947,_0x57c367){var _0x433171={};var _0x11daf7={};var _0x56f13c;var _0x479570;return db[_0xbb6d('0x51')][_0xbb6d('0x66')]({'where':{'id':_0x366d8b[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x4e7947,null))[_0xbb6d('0x1d')](function(_0x498551){if(_0x498551){_0x56f13c=_0x498551;_0x11daf7[_0xbb6d('0x3f')]=_['keys'](db['OpenchannelApplication'][_0xbb6d('0x3c')]);_0x11daf7['query']=_[_0xbb6d('0x42')](_0x366d8b[_0xbb6d('0x41')]);_0x11daf7[_0xbb6d('0x43')]=_[_0xbb6d('0x44')](_0x11daf7['model'],_0x11daf7[_0xbb6d('0x41')]);_0x433171['attributes']=_[_0xbb6d('0x44')](_0x11daf7[_0xbb6d('0x3f')],qs['fields'](_0x366d8b['query'][_0xbb6d('0x46')]));_0x433171['attributes']=_0x433171[_0xbb6d('0x45')][_0xbb6d('0x47')]?_0x433171['attributes']:_0x11daf7[_0xbb6d('0x3f')];_0x433171['order']=qs['sort'](_0x366d8b[_0xbb6d('0x41')][_0xbb6d('0x4a')]);_0x433171[_0xbb6d('0x4b')]=qs[_0xbb6d('0x43')](_[_0xbb6d('0x4c')](_0x366d8b['query'],_0x11daf7['filters']));if(_0x366d8b[_0xbb6d('0x41')][_0xbb6d('0x4f')]){_0x433171[_0xbb6d('0x4b')]=_[_0xbb6d('0x4d')](_0x433171['where'],{'$or':_[_0xbb6d('0x40')](_0x433171[_0xbb6d('0x45')],function(_0x35fdd0){var _0x2a3ee5={};_0x2a3ee5[_0x35fdd0]={'$like':'%'+_0x366d8b[_0xbb6d('0x41')][_0xbb6d('0x4f')]+'%'};return _0x2a3ee5;})});}_0x433171=_[_0xbb6d('0x4d')]({},_0x433171,_0x366d8b[_0xbb6d('0x50')]);return _0x56f13c[_0xbb6d('0xa7')](_0x433171);}})[_0xbb6d('0x1d')](function(_0x55368e){if(_0x55368e){_0x479570=_0x55368e[_0xbb6d('0x47')];if(!_0x366d8b['query'][_0xbb6d('0x48')](_0xbb6d('0x67'))){_0x433171[_0xbb6d('0x2f')]=qs[_0xbb6d('0x2f')](_0x366d8b[_0xbb6d('0x41')][_0xbb6d('0x2f')]);_0x433171[_0xbb6d('0x2e')]=qs[_0xbb6d('0x2e')](_0x366d8b['query'][_0xbb6d('0x2e')]);}return _0x56f13c[_0xbb6d('0xa7')](_0x433171);}})[_0xbb6d('0x1d')](function(_0xd8056b){if(_0xd8056b){return _0xd8056b?{'count':_0x479570,'rows':_0xd8056b}:null;}})[_0xbb6d('0x1d')](respondWithResult(_0x4e7947,null))[_0xbb6d('0x28')](handleError(_0x4e7947,null));};exports[_0xbb6d('0xa8')]=function(_0x5523a9,_0x55099e,_0x218b96){var _0x19cc55={'raw':![],'where':{}};var _0x586026={};var _0x41ee4a={'count':0x0,'rows':[]};return db['OpenchannelAccount'][_0xbb6d('0x66')]({'where':{'id':_0x5523a9[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x55099e,null))[_0xbb6d('0x1d')](function(_0x3db8ee){if(_0x3db8ee){_0x586026[_0xbb6d('0x3f')]=_[_0xbb6d('0x42')](db[_0xbb6d('0x8d')][_0xbb6d('0x3c')]);_0x586026[_0xbb6d('0x41')]=_['keys'](_0x5523a9[_0xbb6d('0x41')]);_0x586026[_0xbb6d('0x43')]=_[_0xbb6d('0x44')](_0x586026[_0xbb6d('0x3f')],_0x586026[_0xbb6d('0x41')]);_0x19cc55[_0xbb6d('0x45')]=_[_0xbb6d('0x44')](_0x586026[_0xbb6d('0x3f')],qs['fields'](_0x5523a9[_0xbb6d('0x41')]['fields']));_0x19cc55['attributes']=_0x19cc55[_0xbb6d('0x45')]['length']?_0x19cc55[_0xbb6d('0x45')]:_0x586026[_0xbb6d('0x3f')];if(!_0x5523a9[_0xbb6d('0x41')]['hasOwnProperty'](_0xbb6d('0x67'))){_0x19cc55[_0xbb6d('0x2f')]=qs[_0xbb6d('0x2f')](_0x5523a9[_0xbb6d('0x41')][_0xbb6d('0x2f')]);_0x19cc55['offset']=qs[_0xbb6d('0x2e')](_0x5523a9['query'][_0xbb6d('0x2e')]);}_0x19cc55[_0xbb6d('0x49')]=qs[_0xbb6d('0x4a')](_0x5523a9['query'][_0xbb6d('0x4a')]);_0x19cc55[_0xbb6d('0x4b')]=qs[_0xbb6d('0x43')](_['pick'](_0x5523a9[_0xbb6d('0x41')],_0x586026[_0xbb6d('0x43')]));_0x19cc55['where'][_0xbb6d('0x63')]=_0x3db8ee['id'];if(_0x5523a9['query'][_0xbb6d('0x4f')]){_0x19cc55[_0xbb6d('0x4b')]=_['merge'](_0x19cc55[_0xbb6d('0x4b')],{'$or':_[_0xbb6d('0x40')](_0x19cc55[_0xbb6d('0x45')],function(_0x3dcff8){var _0xeb3adf={};_0xeb3adf[_0x3dcff8]={'$like':'%'+_0x5523a9[_0xbb6d('0x41')]['filter']+'%'};return _0xeb3adf;})});}_0x19cc55=_[_0xbb6d('0x4d')]({},_0x19cc55,_0x5523a9[_0xbb6d('0x50')]);return db[_0xbb6d('0x8d')][_0xbb6d('0x2d')]({'where':_0x19cc55[_0xbb6d('0x4b')]})[_0xbb6d('0x1d')](function(_0x413b62){_0x41ee4a[_0xbb6d('0x2d')]=_0x413b62;if(_0x5523a9[_0xbb6d('0x41')][_0xbb6d('0x56')]){_0x19cc55[_0xbb6d('0x52')]=[{'model':db[_0xbb6d('0x71')],'as':'Contact','required':![]},{'model':db['User'],'as':_0xbb6d('0xa9'),'attributes':[_0xbb6d('0x39'),'fullname',_0xbb6d('0xaa')],'required':![]},{'model':db[_0xbb6d('0xab')],'as':_0xbb6d('0xac'),'attributes':['id',_0xbb6d('0x39'),'color'],'where':_0x5523a9['query']['tag']?{'id':_0x5523a9[_0xbb6d('0x41')]['tag']}:undefined,'required':_0x5523a9[_0xbb6d('0x41')][_0xbb6d('0xad')]?!![]:![]}];}return db[_0xbb6d('0x8d')][_0xbb6d('0x53')](_0x19cc55);})[_0xbb6d('0x1d')](function(_0x5e85a4){_0x41ee4a[_0xbb6d('0x68')]=_0x5e85a4;return _0x41ee4a;});}})[_0xbb6d('0x1d')](respondWithFilteredResult(_0x55099e,_0x19cc55))[_0xbb6d('0x28')](handleError(_0x55099e,null));};exports[_0xbb6d('0xae')]=function(_0x47b4d7,_0x23b967,_0x3f37d7){return db['OpenchannelAccount'][_0xbb6d('0x5c')]({'where':{'id':_0x47b4d7[_0xbb6d('0x60')]['id']}})['then'](handleEntityNotFound(_0x23b967,null))[_0xbb6d('0x1d')](function(_0x24c3b2){if(_0x24c3b2){return _0x24c3b2[_0xbb6d('0xae')](_0x47b4d7['body'][_0xbb6d('0x6a')],_[_0xbb6d('0xaf')](_0x47b4d7[_0xbb6d('0x58')],[_0xbb6d('0x6a'),'id'])||{})[_0xbb6d('0x8f')](function(_0xe677c1){for(var _0x227052=0x0;_0x227052<_0x47b4d7[_0xbb6d('0x58')]['ids'][_0xbb6d('0x47')];_0x227052+=0x1){socket[_0xbb6d('0xb0')]('userOpenchannelAccount:save',{'UserId':_0x47b4d7[_0xbb6d('0x58')][_0xbb6d('0x6a')][_0x227052],'OpenchannelAccountId':_0x47b4d7[_0xbb6d('0x60')]['id']});}return _0xe677c1;});}})[_0xbb6d('0x1d')](respondWithResult(_0x23b967,null))[_0xbb6d('0x28')](handleError(_0x23b967,null));};exports['removeAgents']=function(_0x46c7f2,_0x42dabe,_0x52d9df){return db['OpenchannelAccount']['find']({'where':{'id':_0x46c7f2[_0xbb6d('0x60')]['id']}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x42dabe,null))['then'](function(_0x336162){if(_0x336162){return _0x336162[_0xbb6d('0xb1')](_0x46c7f2[_0xbb6d('0x41')][_0xbb6d('0x6a')])['then'](function(){if(_['isArray'](_0x46c7f2['query'][_0xbb6d('0x6a')])){for(var _0x2372d0=0x0;_0x2372d0<_0x46c7f2[_0xbb6d('0x41')][_0xbb6d('0x6a')][_0xbb6d('0x47')];_0x2372d0+=0x1){socket[_0xbb6d('0xb0')](_0xbb6d('0xb2'),{'UserId':Number(_0x46c7f2[_0xbb6d('0x41')][_0xbb6d('0x6a')][_0x2372d0]),'OpenchannelAccountId':Number(_0x46c7f2['params']['id'])});}}else{socket[_0xbb6d('0xb0')](_0xbb6d('0xb2'),{'UserId':Number(_0x46c7f2[_0xbb6d('0x41')][_0xbb6d('0x6a')]),'OpenchannelAccountId':Number(_0x46c7f2[_0xbb6d('0x60')]['id'])});}});}})[_0xbb6d('0x1d')](respondWithStatusCode(_0x42dabe,null))['catch'](handleError(_0x42dabe,null));};exports[_0xbb6d('0xb3')]=function(_0x21733f,_0x5f4920,_0x24283f){var _0x1dd4d1={};var _0x4b239e={};var _0x304a90;var _0x4b657a;return db[_0xbb6d('0x51')][_0xbb6d('0x66')]({'where':{'id':_0x21733f[_0xbb6d('0x60')]['id']}})['then'](handleEntityNotFound(_0x5f4920,null))[_0xbb6d('0x1d')](function(_0xca54d1){if(_0xca54d1){_0x304a90=_0xca54d1;_0x4b239e['model']=_['keys'](db['User'][_0xbb6d('0x3c')]);_0x4b239e['query']=_['keys'](_0x21733f[_0xbb6d('0x41')]);_0x4b239e['filters']=_[_0xbb6d('0x44')](_0x4b239e[_0xbb6d('0x3f')],_0x4b239e[_0xbb6d('0x41')]);_0x1dd4d1[_0xbb6d('0x45')]=_['intersection'](_0x4b239e[_0xbb6d('0x3f')],qs[_0xbb6d('0x46')](_0x21733f['query'][_0xbb6d('0x46')]));_0x1dd4d1[_0xbb6d('0x45')]=_0x1dd4d1['attributes'][_0xbb6d('0x47')]?_0x1dd4d1[_0xbb6d('0x45')]:_0x4b239e[_0xbb6d('0x3f')];_0x1dd4d1[_0xbb6d('0x49')]=qs[_0xbb6d('0x4a')](_0x21733f[_0xbb6d('0x41')][_0xbb6d('0x4a')]);_0x1dd4d1[_0xbb6d('0x4b')]=qs[_0xbb6d('0x43')](_[_0xbb6d('0x4c')](_0x21733f['query'],_0x4b239e[_0xbb6d('0x43')]));if(_0x21733f[_0xbb6d('0x41')][_0xbb6d('0x4f')]){_0x1dd4d1[_0xbb6d('0x4b')]=_[_0xbb6d('0x4d')](_0x1dd4d1[_0xbb6d('0x4b')],{'$or':_[_0xbb6d('0x40')](_0x1dd4d1[_0xbb6d('0x45')],function(_0x596470){var _0x23dafe={};_0x23dafe[_0x596470]={'$like':'%'+_0x21733f['query'][_0xbb6d('0x4f')]+'%'};return _0x23dafe;})});}_0x1dd4d1=_[_0xbb6d('0x4d')]({},_0x1dd4d1,_0x21733f['options']);return _0x304a90['getAgents'](_0x1dd4d1);}})['then'](function(_0x8d7604){if(_0x8d7604){_0x4b657a=_0x8d7604[_0xbb6d('0x47')];if(!_0x21733f['query'][_0xbb6d('0x48')](_0xbb6d('0x67'))){_0x1dd4d1[_0xbb6d('0x2f')]=qs[_0xbb6d('0x2f')](_0x21733f[_0xbb6d('0x41')][_0xbb6d('0x2f')]);_0x1dd4d1[_0xbb6d('0x2e')]=qs[_0xbb6d('0x2e')](_0x21733f[_0xbb6d('0x41')][_0xbb6d('0x2e')]);}return _0x304a90['getAgents'](_0x1dd4d1);}})[_0xbb6d('0x1d')](function(_0x134831){if(_0x134831){return _0x134831?{'count':_0x4b657a,'rows':_0x134831}:null;}})[_0xbb6d('0x1d')](respondWithResult(_0x5f4920,null))['catch'](handleError(_0x5f4920,null));};exports[_0xbb6d('0xb4')]=function(_0x17caf9,_0x4cc47e,_0x4d5bf4){var _0x374ddc,_0x4ef056,_0x42930e;if(_[_0xbb6d('0x7b')](_0x17caf9['body']['body'])||_0x17caf9[_0xbb6d('0x58')][_0xbb6d('0x58')]===''){throw new db['Sequelize'][(_0xbb6d('0x73'))](_0xbb6d('0xb5'));}if(_[_0xbb6d('0x7b')](_0x17caf9['body']['to'])){}_0x374ddc=_0x17caf9[_0xbb6d('0x58')]['to'];return db[_0xbb6d('0x51')]['findOne']({'where':{'id':_0x17caf9[_0xbb6d('0x60')]['id']}})['then'](handleEntityNotFound(_0x4cc47e,null))['then'](function(_0x29f8aa){if(_0x29f8aa){return db[_0xbb6d('0x51')][_0xbb6d('0x5c')]({'where':{'id':_0x29f8aa['id']},'include':[{'model':db[_0xbb6d('0x80')],'as':_0xbb6d('0x81'),'include':[{'model':db['CmContact'],'as':_0xbb6d('0x82'),'where':{[_0x29f8aa['mapKey']]:_0x374ddc},'limit':0x1,'order':[[_0xbb6d('0x77'),'DESC']]}]}]})['then'](handleEntityNotFound(_0x4cc47e,null))[_0xbb6d('0x1d')](function(_0x9a13e2){if(_0x9a13e2&&_0x9a13e2[_0xbb6d('0x81')]){_0x4ef056=_0x9a13e2[_0xbb6d('0x35')]({'plain':!![]});if(_0x4ef056[_0xbb6d('0x81')]&&_0x4ef056[_0xbb6d('0x81')][_0xbb6d('0x82')]['length']){return _0x4ef056[_0xbb6d('0x81')]['Contacts'][0x0];}return db[_0xbb6d('0x71')][_0xbb6d('0x57')](_[_0xbb6d('0x15')](_0x17caf9[_0xbb6d('0x58')],{'firstName':_0x374ddc,[_0x9a13e2[_0xbb6d('0x7c')]]:_0x374ddc,'phone':_0x374ddc,'ListId':_0x4ef056[_0xbb6d('0x79')]}));}})[_0xbb6d('0x1d')](handleEntityNotFound(_0x4cc47e,null))[_0xbb6d('0x1d')](function(_0x445157){if(_0x445157){_0x42930e=_0x445157;return db['OpenchannelInteraction']['find']({'where':{'ContactId':_0x42930e['id'],'closed':![],'OpenchannelAccountId':_0x4ef056['id']}})['then'](function(_0x13c7a3){if(_0x13c7a3){return[_0x13c7a3,![]];}return db['OpenchannelInteraction'][_0xbb6d('0x57')]({'UserId':_0x17caf9[_0xbb6d('0x59')]['id'],'ContactId':_0x42930e['id'],'OpenchannelAccountId':_0x4ef056['id'],'lastMsgDirection':'out','Messages':[_[_0xbb6d('0x4d')](_0x17caf9[_0xbb6d('0x58')],{'read':![],'body':_0x17caf9[_0xbb6d('0x58')][_0xbb6d('0x58')],'OpenchannelAccountId':_0x4ef056['id'],'UserId':_0x17caf9[_0xbb6d('0x59')]['id'],'ContactId':_0x42930e['id']})]},{'include':[{'model':db[_0xbb6d('0x98')],'as':_0xbb6d('0xb6')}]})[_0xbb6d('0x1d')](function(_0x53b87e){return[_0x53b87e,!![]];});});}})[_0xbb6d('0x8f')](function(_0x2b10b2,_0x24f7c6){if(_0x24f7c6){return _0x2b10b2;}return db[_0xbb6d('0x98')][_0xbb6d('0x57')](_[_0xbb6d('0x4d')](_0x17caf9[_0xbb6d('0x58')],{'read':![],'body':_0x17caf9[_0xbb6d('0x58')][_0xbb6d('0x58')],'OpenchannelAccountId':_0x4ef056['id'],'OpenchannelInteractionId':_0x2b10b2['id'],'UserId':_0x17caf9[_0xbb6d('0x59')]['id'],'ContactId':_0x42930e['id']}))['then'](function(_0x108178){_0x2b10b2[_0xbb6d('0xb7')][_0xbb6d('0xb6')]=[];_0x2b10b2['dataValues'][_0xbb6d('0xb6')]['push'](_0x108178['dataValues']);return _0x2b10b2;});});}})[_0xbb6d('0x1d')](respondWithResult(_0x4cc47e,null))['catch'](handleError(_0x4cc47e,null));};
\ No newline at end of file