Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index 1ea9c57..50a3fde 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 _0x5fab=['to-csv','squel','crypto','jsforce','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','./openchannelAccount.socket','register','jayson/promise','client','http','request','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','status','json','count','offset','limit','set','Content-Range','apply','reject','destroy','OpenchannelAccounts','UserProfileResource','end','sendStatus','stack','name','Pause','mandatoryDispositionPause','map','OpenchannelAccount','rawAttributes','key','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','include','findAll','rows','show','includeAll','find','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','update','params','describe','OpenchannelAccountId','Disposition','getDispositions','findOne','removeDispositions','addAnswer','getAnswers','CannedAnswer','removeAnswers','ids','notify','openchannel','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','isNil','from','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','CmContact','Contacts','DESC','OpenchannelApplication','Applications','applications','list','orderBy','priority','account','contact','firstName','lastName','threadId','externalUrl','OpenchannelInteraction','ContactId','spread','messageId','interaction','created','push','close','unmanaged','OpenchannelMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','startRouting','EventManager','sequelize','transaction','bulkCreate','getApplications','getInteractions','Contact','Owner','internal','Tag','Tags','color','tag','addAgents','omit','emit','userOpenchannelAccount:save','removeAgents','isArray','getAgents','send','out','Messages','dataValues','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox'];(function(_0x24f571,_0x2fd7d4){var _0x296e1c=function(_0x328466){while(--_0x328466){_0x24f571['push'](_0x24f571['shift']());}};_0x296e1c(++_0x2fd7d4);}(_0x5fab,0x177));var _0xb5fa=function(_0xddb860,_0x344918){_0xddb860=_0xddb860-0x0;var _0x255df9=_0x5fab[_0xddb860];return _0x255df9;};'use strict';var pdf=require(_0xb5fa('0x0'));var emlformat=require(_0xb5fa('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xb5fa('0x2'));var jsonpatch=require(_0xb5fa('0x3'));var rp=require(_0xb5fa('0x4'));var moment=require(_0xb5fa('0x5'));var BPromise=require(_0xb5fa('0x6'));var Mustache=require(_0xb5fa('0x7'));var util=require(_0xb5fa('0x8'));var path=require(_0xb5fa('0x9'));var sox=require(_0xb5fa('0xa'));var csv=require(_0xb5fa('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xb5fa('0xc'));var crypto=require(_0xb5fa('0xd'));var jsforce=require(_0xb5fa('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xb5fa('0xb'));var querystring=require(_0xb5fa('0xf'));var Papa=require(_0xb5fa('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xb5fa('0x11'));var as=require(_0xb5fa('0x12'));var hardwareService=require(_0xb5fa('0x13'));var logger=require(_0xb5fa('0x14'))(_0xb5fa('0x15'));var utils=require(_0xb5fa('0x16'));var config=require(_0xb5fa('0x17'));var licenseUtil=require(_0xb5fa('0x18'));var db=require(_0xb5fa('0x19'))['db'];config['redis']=_[_0xb5fa('0x1a')](config[_0xb5fa('0x1b')],{'host':'localhost','port':0x18eb});var socket=require(_0xb5fa('0x1c'))(new Redis(config['redis']));require(_0xb5fa('0x1d'))[_0xb5fa('0x1e')](socket);var jayson=require(_0xb5fa('0x1f'));var client=jayson[_0xb5fa('0x20')][_0xb5fa('0x21')]({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x38e964,_0x587043,_0x31f252,_0x27c8f7){return new BPromise(function(_0x56fe10,_0x4fabcc){var _0x451a55=_0x27c8f7||client;return _0x451a55[_0xb5fa('0x22')](_0x38e964,_0x31f252)[_0xb5fa('0x23')](function(_0x46eef0){logger[_0xb5fa('0x24')](_0xb5fa('0x25'),_0x587043,_0xb5fa('0x26'));logger[_0xb5fa('0x27')](_0xb5fa('0x28'),_0x587043,_0xb5fa('0x26'),JSON[_0xb5fa('0x29')](_0x46eef0));if(_0x46eef0[_0xb5fa('0x2a')]){if(_0x46eef0['error'][_0xb5fa('0x2b')]===0x1f4){logger['error'](_0xb5fa('0x25'),_0x587043,_0x46eef0['error'][_0xb5fa('0x2c')]);return _0x4fabcc(_0x46eef0[_0xb5fa('0x2a')]['message']);}logger[_0xb5fa('0x2a')](_0xb5fa('0x25'),_0x587043,_0x46eef0[_0xb5fa('0x2a')]['message']);return _0x56fe10(_0x46eef0[_0xb5fa('0x2a')][_0xb5fa('0x2c')]);}else{logger[_0xb5fa('0x24')]('OpenchannelAccount,\x20%s,\x20%s',_0x587043,_0xb5fa('0x26'));_0x56fe10(_0x46eef0['result'][_0xb5fa('0x2c')]);}})[_0xb5fa('0x2d')](function(_0x11053a){logger[_0xb5fa('0x2a')](_0xb5fa('0x25'),_0x587043,_0x11053a);_0x4fabcc(_0x11053a);});});}function respondWithStatusCode(_0x3f61cd,_0x6a455c){_0x6a455c=_0x6a455c||0xcc;return function(_0x20d649){if(_0x20d649){return _0x3f61cd['sendStatus'](_0x6a455c);}return _0x3f61cd['status'](_0x6a455c)['end']();};}function respondWithResult(_0x5a1c39,_0x28a350){_0x28a350=_0x28a350||0xc8;return function(_0x460b54){if(_0x460b54){return _0x5a1c39[_0xb5fa('0x2e')](_0x28a350)[_0xb5fa('0x2f')](_0x460b54);}};}function respondWithFilteredResult(_0x534884,_0x3506a4){return function(_0x358549){if(_0x358549){var _0x353314=_0x358549[_0xb5fa('0x30')],_0x409af9=_0x3506a4[_0xb5fa('0x31')],_0x2a5690=_0x3506a4[_0xb5fa('0x31')]+_0x3506a4[_0xb5fa('0x32')],_0x142bfa;if(_0x2a5690>=_0x353314){_0x2a5690=_0x353314;_0x142bfa=0xc8;}else{_0x142bfa=0xce;}_0x534884[_0xb5fa('0x2e')](_0x142bfa);return _0x534884[_0xb5fa('0x33')](_0xb5fa('0x34'),_0x409af9+'-'+_0x2a5690+'/'+_0x353314)[_0xb5fa('0x2f')](_0x358549);}return null;};}function patchUpdates(_0x319c48){return function(_0x291938){try{jsonpatch[_0xb5fa('0x35')](_0x291938,_0x319c48,!![]);}catch(_0x10fb43){return BPromise[_0xb5fa('0x36')](_0x10fb43);}return _0x291938['save']();};}function saveUpdates(_0x2cc6cb,_0x4d056c){return function(_0x5c7fdd){if(_0x5c7fdd){return _0x5c7fdd['update'](_0x2cc6cb)[_0xb5fa('0x23')](function(_0x502d57){return _0x502d57;});}return null;};}function removeEntity(_0x3bb4de,_0x5876f1){return function(_0x5518b1){if(_0x5518b1){return _0x5518b1[_0xb5fa('0x37')]()[_0xb5fa('0x23')](function(){var _0x4a4bff=_0x5518b1['get']({'plain':!![]});var _0x3d73c2=_0xb5fa('0x38');return db[_0xb5fa('0x39')]['destroy']({'where':{'type':_0x3d73c2,'resourceId':_0x4a4bff['id']}})[_0xb5fa('0x23')](function(){return _0x5518b1;});})[_0xb5fa('0x23')](function(){_0x3bb4de['status'](0xcc)[_0xb5fa('0x3a')]();});}};}function handleEntityNotFound(_0x2056de,_0x204d6b){return function(_0x5580f0){if(!_0x5580f0){_0x2056de[_0xb5fa('0x3b')](0x194);}return _0x5580f0;};}function handleError(_0x2c950e,_0x24ef11){_0x24ef11=_0x24ef11||0x1f4;return function(_0x55bdb7){logger[_0xb5fa('0x2a')](_0x55bdb7[_0xb5fa('0x3c')]);if(_0x55bdb7[_0xb5fa('0x3d')]){delete _0x55bdb7[_0xb5fa('0x3d')];}_0x2c950e['status'](_0x24ef11)['send'](_0x55bdb7);};}exports['index']=function(_0x49e786,_0x5989e1){var _0x4dff5d={'include':[{'model':db[_0xb5fa('0x3e')],'as':_0xb5fa('0x3f')}]},_0x908bc8={},_0x4c0a4d={'count':0x0,'rows':[]};var _0x36db1a=_[_0xb5fa('0x40')](db[_0xb5fa('0x41')][_0xb5fa('0x42')],function(_0x4b4c4c){return{'name':_0x4b4c4c['fieldName'],'type':_0x4b4c4c['type'][_0xb5fa('0x43')]};});_0x908bc8['model']=_[_0xb5fa('0x40')](_0x36db1a,'name');_0x908bc8['query']=_[_0xb5fa('0x44')](_0x49e786[_0xb5fa('0x45')]);_0x908bc8[_0xb5fa('0x46')]=_[_0xb5fa('0x47')](_0x908bc8[_0xb5fa('0x48')],_0x908bc8[_0xb5fa('0x45')]);_0x4dff5d[_0xb5fa('0x49')]=_[_0xb5fa('0x47')](_0x908bc8[_0xb5fa('0x48')],qs[_0xb5fa('0x4a')](_0x49e786['query'][_0xb5fa('0x4a')]));_0x4dff5d['attributes']=_0x4dff5d[_0xb5fa('0x49')][_0xb5fa('0x4b')]?_0x4dff5d[_0xb5fa('0x49')]:_0x908bc8[_0xb5fa('0x48')];if(!_0x49e786[_0xb5fa('0x45')][_0xb5fa('0x4c')](_0xb5fa('0x4d'))){_0x4dff5d[_0xb5fa('0x32')]=qs['limit'](_0x49e786[_0xb5fa('0x45')][_0xb5fa('0x32')]);_0x4dff5d['offset']=qs[_0xb5fa('0x31')](_0x49e786['query'][_0xb5fa('0x31')]);}_0x4dff5d[_0xb5fa('0x4e')]=qs['sort'](_0x49e786['query'][_0xb5fa('0x4f')]);_0x4dff5d[_0xb5fa('0x50')]=qs[_0xb5fa('0x46')](_[_0xb5fa('0x51')](_0x49e786[_0xb5fa('0x45')],_0x908bc8[_0xb5fa('0x46')]),_0x36db1a);if(_0x49e786[_0xb5fa('0x45')][_0xb5fa('0x52')]){_0x4dff5d['where']=_[_0xb5fa('0x53')](_0x4dff5d[_0xb5fa('0x50')],{'$or':_['map'](_0x36db1a,function(_0xee6baa){if(_0xee6baa[_0xb5fa('0x54')]!==_0xb5fa('0x55')){var _0x43b056={};_0x43b056[_0xee6baa[_0xb5fa('0x3d')]]={'$like':'%'+_0x49e786[_0xb5fa('0x45')][_0xb5fa('0x52')]+'%'};return _0x43b056;}})});}_0x4dff5d=_[_0xb5fa('0x53')]({},_0x4dff5d,_0x49e786[_0xb5fa('0x56')]);var _0x464e36={'where':_0x4dff5d[_0xb5fa('0x50')]};return db[_0xb5fa('0x41')][_0xb5fa('0x30')](_0x464e36)[_0xb5fa('0x23')](function(_0x42a359){_0x4c0a4d[_0xb5fa('0x30')]=_0x42a359;if(_0x49e786['query']['includeAll']){_0x4dff5d[_0xb5fa('0x57')]=[{'all':!![]}];}return db['OpenchannelAccount'][_0xb5fa('0x58')](_0x4dff5d);})[_0xb5fa('0x23')](function(_0x5404f6){_0x4c0a4d[_0xb5fa('0x59')]=_0x5404f6;return _0x4c0a4d;})[_0xb5fa('0x23')](respondWithFilteredResult(_0x5989e1,_0x4dff5d))[_0xb5fa('0x2d')](handleError(_0x5989e1,null));};exports[_0xb5fa('0x5a')]=function(_0x471517,_0x3ffee0){var _0x51d5f7={'raw':![],'where':{'id':_0x471517['params']['id']},'include':[{'model':db[_0xb5fa('0x3e')],'as':_0xb5fa('0x3f')}]},_0x27a651={};_0x27a651[_0xb5fa('0x48')]=_['keys'](db[_0xb5fa('0x41')][_0xb5fa('0x42')]);_0x27a651['query']=_['keys'](_0x471517[_0xb5fa('0x45')]);_0x27a651[_0xb5fa('0x46')]=_[_0xb5fa('0x47')](_0x27a651[_0xb5fa('0x48')],_0x27a651[_0xb5fa('0x45')]);_0x51d5f7[_0xb5fa('0x49')]=_[_0xb5fa('0x47')](_0x27a651[_0xb5fa('0x48')],qs[_0xb5fa('0x4a')](_0x471517[_0xb5fa('0x45')][_0xb5fa('0x4a')]));_0x51d5f7[_0xb5fa('0x49')]=_0x51d5f7[_0xb5fa('0x49')][_0xb5fa('0x4b')]?_0x51d5f7[_0xb5fa('0x49')]:_0x27a651[_0xb5fa('0x48')];if(_0x471517[_0xb5fa('0x45')][_0xb5fa('0x5b')]){_0x51d5f7['include']=[{'all':!![]}];}_0x51d5f7=_[_0xb5fa('0x53')]({},_0x51d5f7,_0x471517[_0xb5fa('0x56')]);return db[_0xb5fa('0x41')][_0xb5fa('0x5c')](_0x51d5f7)[_0xb5fa('0x23')](handleEntityNotFound(_0x3ffee0,null))[_0xb5fa('0x23')](respondWithResult(_0x3ffee0,null))[_0xb5fa('0x2d')](handleError(_0x3ffee0,null));};exports[_0xb5fa('0x5d')]=function(_0x1cb39e,_0x1e0547){return db['OpenchannelAccount']['create'](_0x1cb39e[_0xb5fa('0x5e')],{})[_0xb5fa('0x23')](function(_0x1e78cb){var _0x5caf84=_0x1cb39e[_0xb5fa('0x5f')][_0xb5fa('0x60')]({'plain':!![]});if(!_0x5caf84)throw new Error(_0xb5fa('0x61'));if(_0x5caf84[_0xb5fa('0x62')]===_0xb5fa('0x5f')){var _0x9d12f1=_0x1e78cb[_0xb5fa('0x60')]({'plain':!![]});var _0x4f82f0=_0xb5fa('0x38');return db[_0xb5fa('0x63')]['find']({'where':{'name':_0x4f82f0,'userProfileId':_0x5caf84[_0xb5fa('0x64')]},'raw':!![]})[_0xb5fa('0x23')](function(_0x540295){if(_0x540295&&_0x540295[_0xb5fa('0x65')]===0x0){return db[_0xb5fa('0x39')][_0xb5fa('0x5d')]({'name':_0x9d12f1[_0xb5fa('0x3d')],'resourceId':_0x9d12f1['id'],'type':_0x540295[_0xb5fa('0x3d')],'sectionId':_0x540295['id']},{})[_0xb5fa('0x23')](function(){return _0x1e78cb;});}else{return _0x1e78cb;}})[_0xb5fa('0x2d')](function(_0x40d7d5){logger[_0xb5fa('0x2a')](_0xb5fa('0x66'),_0x40d7d5);throw _0x40d7d5;});}return _0x1e78cb;})[_0xb5fa('0x23')](respondWithResult(_0x1e0547,0xc9))[_0xb5fa('0x2d')](handleError(_0x1e0547,null));};exports[_0xb5fa('0x67')]=function(_0x29ffb7,_0x1d6840){if(_0x29ffb7[_0xb5fa('0x5e')]['id']){delete _0x29ffb7[_0xb5fa('0x5e')]['id'];}return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x29ffb7[_0xb5fa('0x68')]['id']},'include':[{'model':db[_0xb5fa('0x3e')],'as':_0xb5fa('0x3f')}]})['then'](handleEntityNotFound(_0x1d6840,null))[_0xb5fa('0x23')](saveUpdates(_0x29ffb7[_0xb5fa('0x5e')],null))[_0xb5fa('0x23')](respondWithResult(_0x1d6840,null))['catch'](handleError(_0x1d6840,null));};exports[_0xb5fa('0x37')]=function(_0x2d786e,_0x58d394){return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x2d786e[_0xb5fa('0x68')]['id']}})['then'](handleEntityNotFound(_0x58d394,null))['then'](removeEntity(_0x58d394,null))[_0xb5fa('0x2d')](handleError(_0x58d394,null));};exports[_0xb5fa('0x69')]=function(_0x432f04,_0x57d8b7){return db[_0xb5fa('0x41')][_0xb5fa('0x69')]()[_0xb5fa('0x23')](respondWithResult(_0x57d8b7,null))[_0xb5fa('0x2d')](handleError(_0x57d8b7,null));};exports['addDisposition']=function(_0x55000b,_0x5cec07,_0x2cbaba){if(_0x55000b[_0xb5fa('0x5e')]['id']){delete _0x55000b[_0xb5fa('0x5e')]['id'];}return db['OpenchannelAccount'][_0xb5fa('0x5c')]({'where':{'id':_0x55000b[_0xb5fa('0x68')]['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x5cec07,null))[_0xb5fa('0x23')](function(_0x2a1872){if(_0x2a1872){_0x55000b[_0xb5fa('0x5e')][_0xb5fa('0x6a')]=_0x2a1872['id'];return db[_0xb5fa('0x6b')][_0xb5fa('0x5d')](_0x55000b[_0xb5fa('0x5e')]);}})[_0xb5fa('0x23')](respondWithResult(_0x5cec07,null))[_0xb5fa('0x2d')](handleError(_0x5cec07,null));};exports[_0xb5fa('0x6c')]=function(_0x38faa6,_0x41127a,_0x5eeaa1){var _0xf173e4={'raw':![],'where':{}};var _0x5a6f74={};var _0x47193c={'count':0x0,'rows':[]};return db[_0xb5fa('0x41')][_0xb5fa('0x6d')]({'where':{'id':_0x38faa6[_0xb5fa('0x68')]['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x41127a,null))['then'](function(_0x1585cd){if(_0x1585cd){_0x5a6f74['model']=_[_0xb5fa('0x44')](db[_0xb5fa('0x6b')][_0xb5fa('0x42')]);_0x5a6f74[_0xb5fa('0x45')]=_['keys'](_0x38faa6['query']);_0x5a6f74['filters']=_[_0xb5fa('0x47')](_0x5a6f74[_0xb5fa('0x48')],_0x5a6f74[_0xb5fa('0x45')]);_0xf173e4[_0xb5fa('0x49')]=_[_0xb5fa('0x47')](_0x5a6f74[_0xb5fa('0x48')],qs['fields'](_0x38faa6[_0xb5fa('0x45')]['fields']));_0xf173e4['attributes']=_0xf173e4[_0xb5fa('0x49')]['length']?_0xf173e4['attributes']:_0x5a6f74['model'];if(!_0x38faa6[_0xb5fa('0x45')]['hasOwnProperty'](_0xb5fa('0x4d'))){_0xf173e4[_0xb5fa('0x32')]=qs[_0xb5fa('0x32')](_0x38faa6['query']['limit']);_0xf173e4[_0xb5fa('0x31')]=qs[_0xb5fa('0x31')](_0x38faa6['query'][_0xb5fa('0x31')]);}_0xf173e4[_0xb5fa('0x4e')]=qs[_0xb5fa('0x4f')](_0x38faa6[_0xb5fa('0x45')]['sort']);_0xf173e4[_0xb5fa('0x50')]=qs[_0xb5fa('0x46')](_[_0xb5fa('0x51')](_0x38faa6[_0xb5fa('0x45')],_0x5a6f74[_0xb5fa('0x46')]));_0xf173e4[_0xb5fa('0x50')][_0xb5fa('0x6a')]=_0x1585cd['id'];if(_0x38faa6['query'][_0xb5fa('0x52')]){_0xf173e4['where']=_[_0xb5fa('0x53')](_0xf173e4[_0xb5fa('0x50')],{'$or':_['map'](_0xf173e4[_0xb5fa('0x49')],function(_0x212d4e){var _0xdc4fe4={};_0xdc4fe4[_0x212d4e]={'$like':'%'+_0x38faa6[_0xb5fa('0x45')][_0xb5fa('0x52')]+'%'};return _0xdc4fe4;})});}_0xf173e4=_[_0xb5fa('0x53')]({},_0xf173e4,_0x38faa6[_0xb5fa('0x56')]);return db[_0xb5fa('0x6b')]['count']({'where':_0xf173e4[_0xb5fa('0x50')]})[_0xb5fa('0x23')](function(_0x2c5357){_0x47193c[_0xb5fa('0x30')]=_0x2c5357;if(_0x38faa6['query']['includeAll']){_0xf173e4['include']=[{'all':!![]}];}return db['Disposition'][_0xb5fa('0x58')](_0xf173e4);})[_0xb5fa('0x23')](function(_0xff504d){_0x47193c[_0xb5fa('0x59')]=_0xff504d;return _0x47193c;});}})['then'](respondWithFilteredResult(_0x41127a,_0xf173e4))['catch'](handleError(_0x41127a,null));};exports[_0xb5fa('0x6e')]=function(_0x55098c,_0x32eebd,_0x35df3c){return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x55098c['params']['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x32eebd,null))['then'](function(_0x46b0a8){if(_0x46b0a8){return _0x46b0a8[_0xb5fa('0x6e')](_0x55098c['query']['ids']);}})[_0xb5fa('0x23')](respondWithStatusCode(_0x32eebd,null))[_0xb5fa('0x2d')](handleError(_0x32eebd,null));};exports[_0xb5fa('0x6f')]=function(_0x1bcca7,_0x20d6b5,_0xa7fd3b){if(_0x1bcca7[_0xb5fa('0x5e')]['id']){delete _0x1bcca7[_0xb5fa('0x5e')]['id'];}return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x1bcca7[_0xb5fa('0x68')]['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x20d6b5,null))[_0xb5fa('0x23')](function(_0x53c7b5){if(_0x53c7b5){_0x1bcca7['body'][_0xb5fa('0x6a')]=_0x53c7b5['id'];return db['CannedAnswer'][_0xb5fa('0x5d')](_0x1bcca7[_0xb5fa('0x5e')]);}})['then'](respondWithResult(_0x20d6b5,null))[_0xb5fa('0x2d')](handleError(_0x20d6b5,null));};exports[_0xb5fa('0x70')]=function(_0x4c2414,_0x45afeb,_0x3ba1d0){var _0x4b9d03={'raw':![],'where':{}};var _0x138c60={};var _0x3a59ed={'count':0x0,'rows':[]};return db[_0xb5fa('0x41')]['findOne']({'where':{'id':_0x4c2414['params']['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x45afeb,null))[_0xb5fa('0x23')](function(_0x3b5e1d){if(_0x3b5e1d){_0x138c60[_0xb5fa('0x48')]=_[_0xb5fa('0x44')](db[_0xb5fa('0x71')][_0xb5fa('0x42')]);_0x138c60[_0xb5fa('0x45')]=_[_0xb5fa('0x44')](_0x4c2414[_0xb5fa('0x45')]);_0x138c60['filters']=_['intersection'](_0x138c60[_0xb5fa('0x48')],_0x138c60[_0xb5fa('0x45')]);_0x4b9d03[_0xb5fa('0x49')]=_[_0xb5fa('0x47')](_0x138c60['model'],qs[_0xb5fa('0x4a')](_0x4c2414[_0xb5fa('0x45')][_0xb5fa('0x4a')]));_0x4b9d03['attributes']=_0x4b9d03[_0xb5fa('0x49')][_0xb5fa('0x4b')]?_0x4b9d03[_0xb5fa('0x49')]:_0x138c60[_0xb5fa('0x48')];if(!_0x4c2414['query'][_0xb5fa('0x4c')](_0xb5fa('0x4d'))){_0x4b9d03[_0xb5fa('0x32')]=qs[_0xb5fa('0x32')](_0x4c2414[_0xb5fa('0x45')][_0xb5fa('0x32')]);_0x4b9d03[_0xb5fa('0x31')]=qs[_0xb5fa('0x31')](_0x4c2414[_0xb5fa('0x45')][_0xb5fa('0x31')]);}_0x4b9d03[_0xb5fa('0x4e')]=qs[_0xb5fa('0x4f')](_0x4c2414[_0xb5fa('0x45')][_0xb5fa('0x4f')]);_0x4b9d03[_0xb5fa('0x50')]=qs['filters'](_[_0xb5fa('0x51')](_0x4c2414[_0xb5fa('0x45')],_0x138c60[_0xb5fa('0x46')]));_0x4b9d03[_0xb5fa('0x50')][_0xb5fa('0x6a')]=_0x3b5e1d['id'];if(_0x4c2414[_0xb5fa('0x45')][_0xb5fa('0x52')]){_0x4b9d03[_0xb5fa('0x50')]=_['merge'](_0x4b9d03['where'],{'$or':_[_0xb5fa('0x40')](_0x4b9d03['attributes'],function(_0x5d0ca8){var _0x3b24fb={};_0x3b24fb[_0x5d0ca8]={'$like':'%'+_0x4c2414[_0xb5fa('0x45')][_0xb5fa('0x52')]+'%'};return _0x3b24fb;})});}_0x4b9d03=_['merge']({},_0x4b9d03,_0x4c2414[_0xb5fa('0x56')]);return db[_0xb5fa('0x71')][_0xb5fa('0x30')]({'where':_0x4b9d03['where']})[_0xb5fa('0x23')](function(_0x6cc978){_0x3a59ed['count']=_0x6cc978;if(_0x4c2414[_0xb5fa('0x45')][_0xb5fa('0x5b')]){_0x4b9d03[_0xb5fa('0x57')]=[{'all':!![]}];}return db[_0xb5fa('0x71')][_0xb5fa('0x58')](_0x4b9d03);})[_0xb5fa('0x23')](function(_0x5fe2fc){_0x3a59ed['rows']=_0x5fe2fc;return _0x3a59ed;});}})[_0xb5fa('0x23')](respondWithFilteredResult(_0x45afeb,_0x4b9d03))[_0xb5fa('0x2d')](handleError(_0x45afeb,null));};exports[_0xb5fa('0x72')]=function(_0x320eda,_0x4c1586,_0x48f335){return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x320eda[_0xb5fa('0x68')]['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x4c1586,null))['then'](function(_0x4ee36b){if(_0x4ee36b){return _0x4ee36b['removeAnswers'](_0x320eda['query'][_0xb5fa('0x73')]);}})[_0xb5fa('0x23')](respondWithStatusCode(_0x4c1586,null))[_0xb5fa('0x2d')](handleError(_0x4c1586,null));};exports[_0xb5fa('0x74')]=function(_0x13deb3,_0x1a19ec,_0x3c36a8){var _0x10502a={'body':_0x13deb3[_0xb5fa('0x5e')],'channel':_0xb5fa('0x75')};var _0x4581ed=[];var _0x5ce5d7=[];var _0x427d61={};var _0x2a6f66=![];return db['CmContact'][_0xb5fa('0x69')]()[_0xb5fa('0x23')](function(_0x5b7d7e){if(!_0x5b7d7e){throw new db[(_0xb5fa('0x76'))][(_0xb5fa('0x77'))](_0xb5fa('0x78'));}_0x4581ed=_[_0xb5fa('0x79')](_[_0xb5fa('0x44')](_0x5b7d7e),[_0xb5fa('0x7a'),_0xb5fa('0x7b')]);_0x5ce5d7=_[_0xb5fa('0x79')](_[_0xb5fa('0x44')](_0x5b7d7e),['createdAt',_0xb5fa('0x7b'),_0xb5fa('0x7c'),_0xb5fa('0x7d')]);if(_0x13deb3[_0xb5fa('0x5e')]['id']){delete _0x13deb3[_0xb5fa('0x5e')]['id'];}if(_[_0xb5fa('0x7e')](_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x7f')])){throw new db['Sequelize'][(_0xb5fa('0x77'))]('from\x20is\x20mandatory');}if(_[_0xb5fa('0x7e')](_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x5e')])||_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x5e')]===''){throw new db[(_0xb5fa('0x76'))][(_0xb5fa('0x77'))](_0xb5fa('0x80'));}if(_[_0xb5fa('0x7e')](_0x13deb3['body']['mapKey'])){throw new db[(_0xb5fa('0x76'))][(_0xb5fa('0x77'))](_0xb5fa('0x81')+_0x5ce5d7);}if(!_[_0xb5fa('0x82')](_0x5ce5d7,_0x13deb3['body'][_0xb5fa('0x83')])){throw new db['Sequelize'][(_0xb5fa('0x77'))](_0xb5fa('0x84')+_0x5ce5d7);}_0x427d61[_0x13deb3['body'][_0xb5fa('0x83')]]=_0x13deb3['body'][_0xb5fa('0x7f')];})['then'](function(){return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x13deb3[_0xb5fa('0x68')]['id']},'include':[{'model':db[_0xb5fa('0x85')],'as':_0xb5fa('0x86'),'include':[{'model':db[_0xb5fa('0x87')],'as':_0xb5fa('0x88'),'where':_0x427d61,'limit':0x1,'order':[[_0xb5fa('0x7b'),_0xb5fa('0x89')]]}]},{'model':db[_0xb5fa('0x8a')],'as':_0xb5fa('0x8b')}]});})['then'](handleEntityNotFound(_0x1a19ec,null))[_0xb5fa('0x23')](function(_0x284b34){if(_0x284b34&&_0x284b34[_0xb5fa('0x86')]){_0x10502a['account']=_0x284b34;_0x10502a[_0xb5fa('0x8c')]=_0x284b34[_0xb5fa('0x8b')];_0x10502a[_0xb5fa('0x8d')]=_0x284b34[_0xb5fa('0x86')];_0x10502a[_0xb5fa('0x8c')]=_[_0xb5fa('0x8e')](_0x10502a[_0xb5fa('0x8c')],[_0xb5fa('0x8f')],['asc']);if(_0x10502a[_0xb5fa('0x90')]['Applications']){delete _0x10502a[_0xb5fa('0x90')][_0xb5fa('0x8b')];}if(_0x10502a[_0xb5fa('0x90')][_0xb5fa('0x86')]&&_0x10502a[_0xb5fa('0x90')][_0xb5fa('0x86')][_0xb5fa('0x88')][_0xb5fa('0x4b')]){return _0x10502a[_0xb5fa('0x90')][_0xb5fa('0x86')][_0xb5fa('0x88')][0x0];}var _0x46f1d3=_[_0xb5fa('0x1a')](_0x13deb3[_0xb5fa('0x5e')],{'firstName':_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x7f')],'ListId':_0x284b34[_0xb5fa('0x7d')]});_0x46f1d3[_0x13deb3['body'][_0xb5fa('0x83')]]=_0x13deb3[_0xb5fa('0x5e')]['from'];return db[_0xb5fa('0x87')][_0xb5fa('0x5d')](_0x46f1d3,{'fields':_0x4581ed,'raw':!![]});}})['then'](handleEntityNotFound(_0x1a19ec,null))['then'](function(_0x486f43){_0x10502a[_0xb5fa('0x91')]=_0x486f43;if(_0x486f43){var _0x5e40be={'ContactId':_0x486f43['id'],'OpenchannelAccountId':_0x13deb3[_0xb5fa('0x68')]['id'],'from':(_0x486f43[_0xb5fa('0x92')]||'')+'\x20'+(_0x486f43[_0xb5fa('0x93')]||'')};var _0x33b3c9={'OpenchannelAccountId':_0x13deb3[_0xb5fa('0x68')]['id'],'closed':![]};if(_0x13deb3['body']['threadId']){_0x33b3c9['threadId']=_0x13deb3[_0xb5fa('0x5e')]['threadId'];return db['OpenchannelInteraction'][_0xb5fa('0x5c')]({'where':_0x33b3c9})['then'](function(_0x8b9718){if(_0x8b9718){return[_0x8b9718,![]];}_0x5e40be[_0xb5fa('0x94')]=_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x94')];_0x5e40be[_0xb5fa('0x95')]=_0x13deb3['body'][_0xb5fa('0x95')];return db[_0xb5fa('0x96')][_0xb5fa('0x5d')](_0x5e40be)[_0xb5fa('0x23')](function(_0x23b70f){return[_0x23b70f,!![]];});});}else{_0x33b3c9['threadId']=null;}_0x33b3c9[_0xb5fa('0x97')]=_0x486f43['id'];return db[_0xb5fa('0x96')][_0xb5fa('0x5c')]({'where':_0x33b3c9})[_0xb5fa('0x23')](function(_0x5364ce){if(_0x5364ce){return[_0x5364ce,![]];}return db[_0xb5fa('0x96')]['create'](_0x5e40be)[_0xb5fa('0x23')](function(_0x390043){return[_0x390043,!![]];});});}})[_0xb5fa('0x98')](function(_0xc6d275,_0x32c191){if(_0xc6d275){_0x2a6f66=_0x32c191;if(!_0x32c191){var _0x802cc0={'from':(_0x10502a[_0xb5fa('0x91')][_0xb5fa('0x92')]||'')+'\x20'+(_0x10502a[_0xb5fa('0x91')][_0xb5fa('0x93')]||'')};if(_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x94')]&&_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x99')]&&_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x94')]!=_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x99')]){_0x802cc0[_0xb5fa('0x94')]=_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x99')];}return _0xc6d275[_0xb5fa('0x67')](_0x802cc0);}else{return _0xc6d275;}}})['then'](function(_0x4cfa95){_0x10502a[_0xb5fa('0x9a')]=_0x4cfa95[_0xb5fa('0x60')]({'plain':!![]});_0x10502a[_0xb5fa('0x9a')][_0xb5fa('0x9b')]=_0x2a6f66;if(_0x10502a[_0xb5fa('0x9a')][_0xb5fa('0x9b')]){if(_0x10502a['account']['autoclose']){_0x10502a['applications'][_0xb5fa('0x9c')]({'id':0x0,'priority':_0x10502a[_0xb5fa('0x8c')]['length']+0x1,'app':_0xb5fa('0x9d'),'appdata':_0xb5fa('0x9e'),'interval':'*,*,*,*'});}}return db[_0xb5fa('0x9f')][_0xb5fa('0x5d')]({'body':_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0x5e')],'OpenchannelAccountId':_0x13deb3[_0xb5fa('0x68')]['id'],'OpenchannelInteractionId':_0x4cfa95['id'],'direction':'in','ContactId':_0x10502a[_0xb5fa('0x91')]['id'],'AttachmentId':_0x13deb3[_0xb5fa('0x5e')][_0xb5fa('0xa0')]});})['then'](function(_0x24a86){_0x10502a['message']=_0x24a86;if(_0x10502a[_0xb5fa('0x9a')][_0xb5fa('0xa1')]){return db[_0xb5fa('0xa2')][_0xb5fa('0x5c')]({'attributes':['id','name'],'where':{'id':_0x10502a[_0xb5fa('0x9a')][_0xb5fa('0xa1')]}})[_0xb5fa('0x23')](function(_0x207a38){if(_0x207a38){_0x10502a['applications'][_0xb5fa('0xa3')]({'id':0x0,'priority':0x0,'app':_0xb5fa('0xa4'),'appdata':_0x207a38[_0xb5fa('0x3d')]+','+(_0x10502a[_0xb5fa('0x90')][_0xb5fa('0xa5')]||0xa),'interval':_0xb5fa('0xa6')});_0x10502a[_0xb5fa('0xa7')]=![];}return respondWithRpcPromise('Start',_0xb5fa('0xa8'),_0x10502a);});}return respondWithRpcPromise('Start',_0xb5fa('0xa8'),_0x10502a);})[_0xb5fa('0x23')](function(_0x412dd1){respondWithRpcPromise(_0xb5fa('0xa9'),_0xb5fa('0xa9'),{'event':_0xb5fa('0x74'),'message':_0x412dd1},client9002);return _0x412dd1;})[_0xb5fa('0x23')](respondWithResult(_0x1a19ec,null))['catch'](handleError(_0x1a19ec,null));};exports['addApplications']=function(_0x331ff8,_0x3d9563,_0x419034){return db[_0xb5fa('0x41')][_0xb5fa('0x6d')]({'where':{'id':_0x331ff8[_0xb5fa('0x68')]['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x3d9563,null))[_0xb5fa('0x23')](function(_0x5b9897){if(_0x5b9897){return db[_0xb5fa('0xaa')][_0xb5fa('0xab')](function(_0x270cda){return db[_0xb5fa('0x8a')][_0xb5fa('0x37')]({'where':{'OpenchannelAccountId':_0x331ff8[_0xb5fa('0x68')]['id']},'transaction':_0x270cda})[_0xb5fa('0x23')](function(_0x2182b3){var _0x330d32=_['map'](_0x331ff8[_0xb5fa('0x5e')],function(_0x5996d6){_0x5996d6[_0xb5fa('0x6a')]=_0x331ff8[_0xb5fa('0x68')]['id'];return _0x5996d6;});return db[_0xb5fa('0x8a')][_0xb5fa('0xac')](_0x330d32,{'transaction':_0x270cda});});})[_0xb5fa('0x23')](function(){return db[_0xb5fa('0x8a')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0x331ff8[_0xb5fa('0x68')]['id']},'order':_0xb5fa('0x8f')});});}})[_0xb5fa('0x23')](respondWithResult(_0x3d9563,null))[_0xb5fa('0x2d')](handleError(_0x3d9563,null));};exports[_0xb5fa('0xad')]=function(_0x21951e,_0x4444da,_0x55ec26){var _0x5d0e21={};var _0x405677={};var _0x3a8dad;var _0x2254fa;return db[_0xb5fa('0x41')][_0xb5fa('0x6d')]({'where':{'id':_0x21951e[_0xb5fa('0x68')]['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x4444da,null))[_0xb5fa('0x23')](function(_0x31c103){if(_0x31c103){_0x3a8dad=_0x31c103;_0x405677[_0xb5fa('0x48')]=_['keys'](db[_0xb5fa('0x8a')][_0xb5fa('0x42')]);_0x405677[_0xb5fa('0x45')]=_[_0xb5fa('0x44')](_0x21951e[_0xb5fa('0x45')]);_0x405677[_0xb5fa('0x46')]=_[_0xb5fa('0x47')](_0x405677[_0xb5fa('0x48')],_0x405677[_0xb5fa('0x45')]);_0x5d0e21[_0xb5fa('0x49')]=_[_0xb5fa('0x47')](_0x405677[_0xb5fa('0x48')],qs[_0xb5fa('0x4a')](_0x21951e[_0xb5fa('0x45')]['fields']));_0x5d0e21['attributes']=_0x5d0e21[_0xb5fa('0x49')][_0xb5fa('0x4b')]?_0x5d0e21['attributes']:_0x405677[_0xb5fa('0x48')];_0x5d0e21[_0xb5fa('0x4e')]=qs[_0xb5fa('0x4f')](_0x21951e['query'][_0xb5fa('0x4f')]);_0x5d0e21[_0xb5fa('0x50')]=qs[_0xb5fa('0x46')](_[_0xb5fa('0x51')](_0x21951e[_0xb5fa('0x45')],_0x405677[_0xb5fa('0x46')]));if(_0x21951e[_0xb5fa('0x45')][_0xb5fa('0x52')]){_0x5d0e21['where']=_[_0xb5fa('0x53')](_0x5d0e21[_0xb5fa('0x50')],{'$or':_['map'](_0x5d0e21[_0xb5fa('0x49')],function(_0xafec2d){var _0x567ad1={};_0x567ad1[_0xafec2d]={'$like':'%'+_0x21951e[_0xb5fa('0x45')][_0xb5fa('0x52')]+'%'};return _0x567ad1;})});}_0x5d0e21=_[_0xb5fa('0x53')]({},_0x5d0e21,_0x21951e[_0xb5fa('0x56')]);return _0x3a8dad[_0xb5fa('0xad')](_0x5d0e21);}})[_0xb5fa('0x23')](function(_0x192c76){if(_0x192c76){_0x2254fa=_0x192c76[_0xb5fa('0x4b')];if(!_0x21951e['query'][_0xb5fa('0x4c')](_0xb5fa('0x4d'))){_0x5d0e21[_0xb5fa('0x32')]=qs[_0xb5fa('0x32')](_0x21951e[_0xb5fa('0x45')]['limit']);_0x5d0e21[_0xb5fa('0x31')]=qs[_0xb5fa('0x31')](_0x21951e[_0xb5fa('0x45')]['offset']);}return _0x3a8dad[_0xb5fa('0xad')](_0x5d0e21);}})[_0xb5fa('0x23')](function(_0x3c5c67){if(_0x3c5c67){return _0x3c5c67?{'count':_0x2254fa,'rows':_0x3c5c67}:null;}})['then'](respondWithResult(_0x4444da,null))[_0xb5fa('0x2d')](handleError(_0x4444da,null));};exports[_0xb5fa('0xae')]=function(_0x14f4b9,_0x2c1eb6,_0xbe63f8){var _0xc21f50={'raw':![],'where':{}};var _0x266eff={};var _0xae1424={'count':0x0,'rows':[]};return db[_0xb5fa('0x41')]['findOne']({'where':{'id':_0x14f4b9[_0xb5fa('0x68')]['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x2c1eb6,null))[_0xb5fa('0x23')](function(_0x4e65cc){if(_0x4e65cc){_0x266eff['model']=_['keys'](db['OpenchannelInteraction']['rawAttributes']);_0x266eff[_0xb5fa('0x45')]=_[_0xb5fa('0x44')](_0x14f4b9[_0xb5fa('0x45')]);_0x266eff[_0xb5fa('0x46')]=_[_0xb5fa('0x47')](_0x266eff[_0xb5fa('0x48')],_0x266eff[_0xb5fa('0x45')]);_0xc21f50[_0xb5fa('0x49')]=_[_0xb5fa('0x47')](_0x266eff[_0xb5fa('0x48')],qs['fields'](_0x14f4b9['query'][_0xb5fa('0x4a')]));_0xc21f50[_0xb5fa('0x49')]=_0xc21f50[_0xb5fa('0x49')]['length']?_0xc21f50['attributes']:_0x266eff[_0xb5fa('0x48')];if(!_0x14f4b9[_0xb5fa('0x45')][_0xb5fa('0x4c')](_0xb5fa('0x4d'))){_0xc21f50[_0xb5fa('0x32')]=qs[_0xb5fa('0x32')](_0x14f4b9[_0xb5fa('0x45')][_0xb5fa('0x32')]);_0xc21f50[_0xb5fa('0x31')]=qs['offset'](_0x14f4b9[_0xb5fa('0x45')][_0xb5fa('0x31')]);}_0xc21f50[_0xb5fa('0x4e')]=qs[_0xb5fa('0x4f')](_0x14f4b9[_0xb5fa('0x45')][_0xb5fa('0x4f')]);_0xc21f50[_0xb5fa('0x50')]=qs[_0xb5fa('0x46')](_['pick'](_0x14f4b9[_0xb5fa('0x45')],_0x266eff[_0xb5fa('0x46')]));_0xc21f50['where']['OpenchannelAccountId']=_0x4e65cc['id'];if(_0x14f4b9[_0xb5fa('0x45')]['filter']){_0xc21f50[_0xb5fa('0x50')]=_[_0xb5fa('0x53')](_0xc21f50[_0xb5fa('0x50')],{'$or':_[_0xb5fa('0x40')](_0xc21f50[_0xb5fa('0x49')],function(_0x283367){var _0xa3b3d7={};_0xa3b3d7[_0x283367]={'$like':'%'+_0x14f4b9[_0xb5fa('0x45')]['filter']+'%'};return _0xa3b3d7;})});}_0xc21f50=_[_0xb5fa('0x53')]({},_0xc21f50,_0x14f4b9[_0xb5fa('0x56')]);return db[_0xb5fa('0x96')][_0xb5fa('0x30')]({'where':_0xc21f50['where']})[_0xb5fa('0x23')](function(_0x12733b){_0xae1424['count']=_0x12733b;if(_0x14f4b9[_0xb5fa('0x45')][_0xb5fa('0x5b')]){_0xc21f50['include']=[{'model':db[_0xb5fa('0x87')],'as':_0xb5fa('0xaf'),'required':![]},{'model':db['User'],'as':_0xb5fa('0xb0'),'attributes':['name','fullname',_0xb5fa('0xb1')],'required':![]},{'model':db[_0xb5fa('0xb2')],'as':_0xb5fa('0xb3'),'attributes':['id',_0xb5fa('0x3d'),_0xb5fa('0xb4')],'where':_0x14f4b9[_0xb5fa('0x45')][_0xb5fa('0xb5')]?{'id':_0x14f4b9['query'][_0xb5fa('0xb5')]}:undefined,'required':_0x14f4b9[_0xb5fa('0x45')]['tag']?!![]:![]}];}return db['OpenchannelInteraction'][_0xb5fa('0x58')](_0xc21f50);})[_0xb5fa('0x23')](function(_0x689653){_0xae1424['rows']=_0x689653;return _0xae1424;});}})[_0xb5fa('0x23')](respondWithFilteredResult(_0x2c1eb6,_0xc21f50))['catch'](handleError(_0x2c1eb6,null));};exports[_0xb5fa('0xb6')]=function(_0x48d5b9,_0x4051b0,_0x229823){return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x48d5b9[_0xb5fa('0x68')]['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x4051b0,null))[_0xb5fa('0x23')](function(_0x52fb1e){if(_0x52fb1e){return _0x52fb1e[_0xb5fa('0xb6')](_0x48d5b9[_0xb5fa('0x5e')]['ids'],_[_0xb5fa('0xb7')](_0x48d5b9['body'],[_0xb5fa('0x73'),'id'])||{})[_0xb5fa('0x98')](function(_0x477274){for(var _0x165b0a=0x0;_0x165b0a<_0x48d5b9['body'][_0xb5fa('0x73')]['length'];_0x165b0a+=0x1){socket[_0xb5fa('0xb8')](_0xb5fa('0xb9'),{'UserId':_0x48d5b9['body'][_0xb5fa('0x73')][_0x165b0a],'OpenchannelAccountId':_0x48d5b9[_0xb5fa('0x68')]['id']});}return _0x477274;});}})[_0xb5fa('0x23')](respondWithResult(_0x4051b0,null))[_0xb5fa('0x2d')](handleError(_0x4051b0,null));};exports[_0xb5fa('0xba')]=function(_0x5313ef,_0x45e2a1,_0x5217a1){return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x5313ef['params']['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x45e2a1,null))[_0xb5fa('0x23')](function(_0x4d58d3){if(_0x4d58d3){return _0x4d58d3['removeAgents'](_0x5313ef[_0xb5fa('0x45')][_0xb5fa('0x73')])[_0xb5fa('0x23')](function(){if(_[_0xb5fa('0xbb')](_0x5313ef[_0xb5fa('0x45')][_0xb5fa('0x73')])){for(var _0x257d8a=0x0;_0x257d8a<_0x5313ef[_0xb5fa('0x45')][_0xb5fa('0x73')][_0xb5fa('0x4b')];_0x257d8a+=0x1){socket['emit']('userOpenchannelAccount:remove',{'UserId':Number(_0x5313ef['query'][_0xb5fa('0x73')][_0x257d8a]),'OpenchannelAccountId':Number(_0x5313ef[_0xb5fa('0x68')]['id'])});}}else{socket['emit']('userOpenchannelAccount:remove',{'UserId':Number(_0x5313ef['query']['ids']),'OpenchannelAccountId':Number(_0x5313ef[_0xb5fa('0x68')]['id'])});}});}})['then'](respondWithStatusCode(_0x45e2a1,null))[_0xb5fa('0x2d')](handleError(_0x45e2a1,null));};exports[_0xb5fa('0xbc')]=function(_0x189e6b,_0x56414f,_0xec1ba4){var _0x775934={};var _0x5c8311={};var _0x31e2a1;var _0xcf6d4d;return db['OpenchannelAccount']['findOne']({'where':{'id':_0x189e6b['params']['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x56414f,null))[_0xb5fa('0x23')](function(_0x207c1e){if(_0x207c1e){_0x31e2a1=_0x207c1e;_0x5c8311['model']=_[_0xb5fa('0x44')](db[_0xb5fa('0xa2')][_0xb5fa('0x42')]);_0x5c8311[_0xb5fa('0x45')]=_[_0xb5fa('0x44')](_0x189e6b['query']);_0x5c8311[_0xb5fa('0x46')]=_['intersection'](_0x5c8311[_0xb5fa('0x48')],_0x5c8311[_0xb5fa('0x45')]);_0x775934[_0xb5fa('0x49')]=_[_0xb5fa('0x47')](_0x5c8311[_0xb5fa('0x48')],qs[_0xb5fa('0x4a')](_0x189e6b[_0xb5fa('0x45')][_0xb5fa('0x4a')]));_0x775934[_0xb5fa('0x49')]=_0x775934['attributes']['length']?_0x775934[_0xb5fa('0x49')]:_0x5c8311[_0xb5fa('0x48')];_0x775934['order']=qs[_0xb5fa('0x4f')](_0x189e6b[_0xb5fa('0x45')]['sort']);_0x775934[_0xb5fa('0x50')]=qs[_0xb5fa('0x46')](_[_0xb5fa('0x51')](_0x189e6b['query'],_0x5c8311[_0xb5fa('0x46')]));if(_0x189e6b[_0xb5fa('0x45')][_0xb5fa('0x52')]){_0x775934[_0xb5fa('0x50')]=_[_0xb5fa('0x53')](_0x775934['where'],{'$or':_[_0xb5fa('0x40')](_0x775934[_0xb5fa('0x49')],function(_0x3e1cc3){var _0x268214={};_0x268214[_0x3e1cc3]={'$like':'%'+_0x189e6b[_0xb5fa('0x45')]['filter']+'%'};return _0x268214;})});}_0x775934=_['merge']({},_0x775934,_0x189e6b[_0xb5fa('0x56')]);return _0x31e2a1[_0xb5fa('0xbc')](_0x775934);}})[_0xb5fa('0x23')](function(_0x34e4a1){if(_0x34e4a1){_0xcf6d4d=_0x34e4a1[_0xb5fa('0x4b')];if(!_0x189e6b['query']['hasOwnProperty']('nolimit')){_0x775934[_0xb5fa('0x32')]=qs[_0xb5fa('0x32')](_0x189e6b['query'][_0xb5fa('0x32')]);_0x775934[_0xb5fa('0x31')]=qs[_0xb5fa('0x31')](_0x189e6b[_0xb5fa('0x45')][_0xb5fa('0x31')]);}return _0x31e2a1['getAgents'](_0x775934);}})[_0xb5fa('0x23')](function(_0x4fe897){if(_0x4fe897){return _0x4fe897?{'count':_0xcf6d4d,'rows':_0x4fe897}:null;}})[_0xb5fa('0x23')](respondWithResult(_0x56414f,null))[_0xb5fa('0x2d')](handleError(_0x56414f,null));};exports[_0xb5fa('0xbd')]=function(_0x30ebb3,_0x1db92b,_0x70575a){var _0x29717c,_0xdfea60,_0x42a3e9;if(_['isNil'](_0x30ebb3[_0xb5fa('0x5e')][_0xb5fa('0x5e')])||_0x30ebb3[_0xb5fa('0x5e')][_0xb5fa('0x5e')]===''){throw new db['Sequelize'][(_0xb5fa('0x77'))](_0xb5fa('0x80'));}if(_['isNil'](_0x30ebb3['body']['to'])){}_0x29717c=_0x30ebb3[_0xb5fa('0x5e')]['to'];return db[_0xb5fa('0x41')]['findOne']({'where':{'id':_0x30ebb3['params']['id']}})[_0xb5fa('0x23')](handleEntityNotFound(_0x1db92b,null))[_0xb5fa('0x23')](function(_0x274a31){if(_0x274a31){return db[_0xb5fa('0x41')][_0xb5fa('0x5c')]({'where':{'id':_0x274a31['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db[_0xb5fa('0x87')],'as':'Contacts','where':{[_0x274a31[_0xb5fa('0x83')]]:_0x29717c},'limit':0x1,'order':[['updatedAt',_0xb5fa('0x89')]]}]}]})[_0xb5fa('0x23')](handleEntityNotFound(_0x1db92b,null))['then'](function(_0x4e2ee3){if(_0x4e2ee3&&_0x4e2ee3[_0xb5fa('0x86')]){_0xdfea60=_0x4e2ee3['get']({'plain':!![]});if(_0xdfea60[_0xb5fa('0x86')]&&_0xdfea60[_0xb5fa('0x86')]['Contacts'][_0xb5fa('0x4b')]){return _0xdfea60[_0xb5fa('0x86')][_0xb5fa('0x88')][0x0];}return db['CmContact'][_0xb5fa('0x5d')](_[_0xb5fa('0x1a')](_0x30ebb3['body'],{'firstName':_0x29717c,[_0x4e2ee3[_0xb5fa('0x83')]]:_0x29717c,'phone':_0x29717c,'ListId':_0xdfea60[_0xb5fa('0x7d')]}));}})[_0xb5fa('0x23')](handleEntityNotFound(_0x1db92b,null))[_0xb5fa('0x23')](function(_0x1fd50){if(_0x1fd50){_0x42a3e9=_0x1fd50;return db[_0xb5fa('0x96')][_0xb5fa('0x5c')]({'where':{'ContactId':_0x42a3e9['id'],'closed':![],'OpenchannelAccountId':_0xdfea60['id']}})[_0xb5fa('0x23')](function(_0xf2f3d0){if(_0xf2f3d0){return[_0xf2f3d0,![]];}return db[_0xb5fa('0x96')][_0xb5fa('0x5d')]({'UserId':_0x30ebb3[_0xb5fa('0x5f')]['id'],'ContactId':_0x42a3e9['id'],'OpenchannelAccountId':_0xdfea60['id'],'lastMsgDirection':_0xb5fa('0xbe'),'Messages':[_[_0xb5fa('0x53')](_0x30ebb3[_0xb5fa('0x5e')],{'read':![],'body':_0x30ebb3[_0xb5fa('0x5e')][_0xb5fa('0x5e')],'OpenchannelAccountId':_0xdfea60['id'],'UserId':_0x30ebb3[_0xb5fa('0x5f')]['id'],'ContactId':_0x42a3e9['id']})]},{'include':[{'model':db[_0xb5fa('0x9f')],'as':_0xb5fa('0xbf')}]})[_0xb5fa('0x23')](function(_0x2bc5c5){return[_0x2bc5c5,!![]];});});}})[_0xb5fa('0x98')](function(_0x39621f,_0x58907b){if(_0x58907b){return _0x39621f;}return db[_0xb5fa('0x9f')][_0xb5fa('0x5d')](_[_0xb5fa('0x53')](_0x30ebb3[_0xb5fa('0x5e')],{'read':![],'body':_0x30ebb3[_0xb5fa('0x5e')][_0xb5fa('0x5e')],'OpenchannelAccountId':_0xdfea60['id'],'OpenchannelInteractionId':_0x39621f['id'],'UserId':_0x30ebb3['user']['id'],'ContactId':_0x42a3e9['id']}))[_0xb5fa('0x23')](function(_0x40a0d7){_0x39621f[_0xb5fa('0xc0')][_0xb5fa('0xbf')]=[];_0x39621f[_0xb5fa('0xc0')][_0xb5fa('0xbf')][_0xb5fa('0x9c')](_0x40a0d7[_0xb5fa('0xc0')]);return _0x39621f;});});}})[_0xb5fa('0x23')](respondWithResult(_0x1db92b,null))[_0xb5fa('0x2d')](handleError(_0x1db92b,null));};
\ No newline at end of file