Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index f1ecd84..d9cb86a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xafc4=['merge','options','count','includeAll','include','findAll','rows','show','params','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','describe','addDisposition','Disposition','getDispositions','findOne','OpenchannelAccountId','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','openchannel','CmContact','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','isNil','Sequelize','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','Applications','account','applications','list','orderBy','asc','contact','firstName','lastName','threadId','OpenchannelInteraction','externalUrl','spread','messageId','interaction','created','autoclose','close','unmanaged','OpenchannelMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','notify','addApplications','sequelize','OpenchannelApplication','bulkCreate','getApplications','Owner','Tag','Tags','color','tag','addAgents','omit','userOpenchannelAccount:save','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','send','body\x20is\x20mandatory\x20and\x20not\x20empty','DESC','out','dataValues','Messages','push','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','jayson/promise','client','http','request','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','end','offset','limit','status','set','Content-Range','apply','reject','save','update','destroy','OpenchannelAccounts','UserProfileResource','name','index','Pause','mandatoryDispositionPause','map','OpenchannelAccount','rawAttributes','fieldName','type','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter'];(function(_0x4b9b50,_0x313b7d){var _0x204cfa=function(_0x2031d6){while(--_0x2031d6){_0x4b9b50['push'](_0x4b9b50['shift']());}};_0x204cfa(++_0x313b7d);}(_0xafc4,0x69));var _0x4afc=function(_0x1d1c66,_0x33b222){_0x1d1c66=_0x1d1c66-0x0;var _0x675bc2=_0xafc4[_0x1d1c66];return _0x675bc2;};'use strict';var pdf=require(_0x4afc('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x4afc('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x4afc('0x2'));var rp=require(_0x4afc('0x3'));var moment=require(_0x4afc('0x4'));var BPromise=require(_0x4afc('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x4afc('0x6'));var csv=require(_0x4afc('0x7'));var ejs=require(_0x4afc('0x8'));var fs=require('fs');var _=require(_0x4afc('0x9'));var squel=require(_0x4afc('0xa'));var crypto=require(_0x4afc('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x4afc('0xc'));var toCsv=require(_0x4afc('0x7'));var querystring=require(_0x4afc('0xd'));var Papa=require(_0x4afc('0xe'));var Redis=require(_0x4afc('0xf'));var authService=require(_0x4afc('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4afc('0x11'));var logger=require('../../config/logger')(_0x4afc('0x12'));var utils=require(_0x4afc('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0x4afc('0x14'));var db=require(_0x4afc('0x15'))['db'];config[_0x4afc('0x16')]=_[_0x4afc('0x17')](config[_0x4afc('0x16')],{'host':_0x4afc('0x18'),'port':0x18eb});var socket=require(_0x4afc('0x19'))(new Redis(config[_0x4afc('0x16')]));require('./openchannelAccount.socket')[_0x4afc('0x1a')](socket);var jayson=require(_0x4afc('0x1b'));var client=jayson[_0x4afc('0x1c')][_0x4afc('0x1d')]({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x2452ae,_0x4f3127,_0x23ae30,_0x24ed6d){return new BPromise(function(_0x2b928b,_0x31eec4){var _0x3a306f=_0x24ed6d||client;return _0x3a306f[_0x4afc('0x1e')](_0x2452ae,_0x23ae30)[_0x4afc('0x1f')](function(_0x3ad418){logger[_0x4afc('0x20')](_0x4afc('0x21'),_0x4f3127,_0x4afc('0x22'));logger['debug'](_0x4afc('0x23'),_0x4f3127,_0x4afc('0x22'),JSON[_0x4afc('0x24')](_0x3ad418));if(_0x3ad418[_0x4afc('0x25')]){if(_0x3ad418['error'][_0x4afc('0x26')]===0x1f4){logger[_0x4afc('0x25')](_0x4afc('0x21'),_0x4f3127,_0x3ad418[_0x4afc('0x25')][_0x4afc('0x27')]);return _0x31eec4(_0x3ad418[_0x4afc('0x25')][_0x4afc('0x27')]);}logger['error'](_0x4afc('0x21'),_0x4f3127,_0x3ad418[_0x4afc('0x25')]['message']);return _0x2b928b(_0x3ad418[_0x4afc('0x25')]['message']);}else{logger[_0x4afc('0x20')](_0x4afc('0x21'),_0x4f3127,_0x4afc('0x22'));_0x2b928b(_0x3ad418[_0x4afc('0x28')][_0x4afc('0x27')]);}})[_0x4afc('0x29')](function(_0x40a0db){logger[_0x4afc('0x25')](_0x4afc('0x21'),_0x4f3127,_0x40a0db);_0x31eec4(_0x40a0db);});});}function respondWithStatusCode(_0x100220,_0x4e8273){_0x4e8273=_0x4e8273||0xcc;return function(_0x359c07){if(_0x359c07){return _0x100220[_0x4afc('0x2a')](_0x4e8273);}return _0x100220['status'](_0x4e8273)[_0x4afc('0x2b')]();};}function respondWithResult(_0x244f6c,_0x2d6112){_0x2d6112=_0x2d6112||0xc8;return function(_0x4e254d){if(_0x4e254d){return _0x244f6c['status'](_0x2d6112)['json'](_0x4e254d);}};}function respondWithFilteredResult(_0x426e9d,_0x5db47e){return function(_0x5e4747){if(_0x5e4747){var _0xd26d2f=_0x5e4747['count'],_0x628e42=_0x5db47e[_0x4afc('0x2c')],_0x494fe7=_0x5db47e[_0x4afc('0x2c')]+_0x5db47e[_0x4afc('0x2d')],_0x514278;if(_0x494fe7>=_0xd26d2f){_0x494fe7=_0xd26d2f;_0x514278=0xc8;}else{_0x514278=0xce;}_0x426e9d[_0x4afc('0x2e')](_0x514278);return _0x426e9d[_0x4afc('0x2f')](_0x4afc('0x30'),_0x628e42+'-'+_0x494fe7+'/'+_0xd26d2f)['json'](_0x5e4747);}return null;};}function patchUpdates(_0x290391){return function(_0x3d1693){try{jsonpatch[_0x4afc('0x31')](_0x3d1693,_0x290391,!![]);}catch(_0x2f178c){return BPromise[_0x4afc('0x32')](_0x2f178c);}return _0x3d1693[_0x4afc('0x33')]();};}function saveUpdates(_0xbabe1e,_0x406789){return function(_0x5ac7a8){if(_0x5ac7a8){return _0x5ac7a8[_0x4afc('0x34')](_0xbabe1e)['then'](function(_0x539b61){return _0x539b61;});}return null;};}function removeEntity(_0x324a12,_0x33ebbc){return function(_0x266f7f){if(_0x266f7f){return _0x266f7f[_0x4afc('0x35')]()[_0x4afc('0x1f')](function(){var _0x3f50cc=_0x266f7f['get']({'plain':!![]});var _0x380f9f=_0x4afc('0x36');return db[_0x4afc('0x37')][_0x4afc('0x35')]({'where':{'type':_0x380f9f,'resourceId':_0x3f50cc['id']}})[_0x4afc('0x1f')](function(){return _0x266f7f;});})[_0x4afc('0x1f')](function(){_0x324a12['status'](0xcc)[_0x4afc('0x2b')]();});}};}function handleEntityNotFound(_0x2ddce1,_0x91565d){return function(_0x283bc2){if(!_0x283bc2){_0x2ddce1['sendStatus'](0x194);}return _0x283bc2;};}function handleError(_0x4be1e6,_0x43c341){_0x43c341=_0x43c341||0x1f4;return function(_0x22bd75){logger[_0x4afc('0x25')](_0x22bd75['stack']);if(_0x22bd75['name']){delete _0x22bd75[_0x4afc('0x38')];}_0x4be1e6['status'](_0x43c341)['send'](_0x22bd75);};}exports[_0x4afc('0x39')]=function(_0x1dc853,_0x2be40e){var _0x3e41f5={'include':[{'model':db[_0x4afc('0x3a')],'as':_0x4afc('0x3b')}]},_0x395bc6={},_0x4420fb={'count':0x0,'rows':[]};var _0x3ccc5a=_[_0x4afc('0x3c')](db[_0x4afc('0x3d')][_0x4afc('0x3e')],function(_0x15c6cb){return{'name':_0x15c6cb[_0x4afc('0x3f')],'type':_0x15c6cb[_0x4afc('0x40')]['key']};});_0x395bc6[_0x4afc('0x41')]=_[_0x4afc('0x3c')](_0x3ccc5a,_0x4afc('0x38'));_0x395bc6[_0x4afc('0x42')]=_[_0x4afc('0x43')](_0x1dc853[_0x4afc('0x42')]);_0x395bc6[_0x4afc('0x44')]=_['intersection'](_0x395bc6['model'],_0x395bc6['query']);_0x3e41f5[_0x4afc('0x45')]=_[_0x4afc('0x46')](_0x395bc6['model'],qs[_0x4afc('0x47')](_0x1dc853[_0x4afc('0x42')][_0x4afc('0x47')]));_0x3e41f5[_0x4afc('0x45')]=_0x3e41f5['attributes'][_0x4afc('0x48')]?_0x3e41f5[_0x4afc('0x45')]:_0x395bc6[_0x4afc('0x41')];if(!_0x1dc853[_0x4afc('0x42')][_0x4afc('0x49')](_0x4afc('0x4a'))){_0x3e41f5['limit']=qs[_0x4afc('0x2d')](_0x1dc853['query'][_0x4afc('0x2d')]);_0x3e41f5[_0x4afc('0x2c')]=qs[_0x4afc('0x2c')](_0x1dc853['query']['offset']);}_0x3e41f5[_0x4afc('0x4b')]=qs[_0x4afc('0x4c')](_0x1dc853[_0x4afc('0x42')][_0x4afc('0x4c')]);_0x3e41f5[_0x4afc('0x4d')]=qs[_0x4afc('0x44')](_[_0x4afc('0x4e')](_0x1dc853[_0x4afc('0x42')],_0x395bc6['filters']),_0x3ccc5a);if(_0x1dc853[_0x4afc('0x42')][_0x4afc('0x4f')]){_0x3e41f5['where']=_[_0x4afc('0x50')](_0x3e41f5['where'],{'$or':_[_0x4afc('0x3c')](_0x3ccc5a,function(_0x24a731){if(_0x24a731[_0x4afc('0x40')]!=='VIRTUAL'){var _0xd0f517={};_0xd0f517[_0x24a731[_0x4afc('0x38')]]={'$like':'%'+_0x1dc853[_0x4afc('0x42')][_0x4afc('0x4f')]+'%'};return _0xd0f517;}})});}_0x3e41f5=_[_0x4afc('0x50')]({},_0x3e41f5,_0x1dc853[_0x4afc('0x51')]);var _0x5d9d90={'where':_0x3e41f5['where']};return db['OpenchannelAccount'][_0x4afc('0x52')](_0x5d9d90)[_0x4afc('0x1f')](function(_0x42e274){_0x4420fb[_0x4afc('0x52')]=_0x42e274;if(_0x1dc853[_0x4afc('0x42')][_0x4afc('0x53')]){_0x3e41f5[_0x4afc('0x54')]=[{'all':!![]}];}return db[_0x4afc('0x3d')][_0x4afc('0x55')](_0x3e41f5);})[_0x4afc('0x1f')](function(_0x48dbe3){_0x4420fb[_0x4afc('0x56')]=_0x48dbe3;return _0x4420fb;})['then'](respondWithFilteredResult(_0x2be40e,_0x3e41f5))['catch'](handleError(_0x2be40e,null));};exports[_0x4afc('0x57')]=function(_0x5c7606,_0x428d78){var _0x355198={'raw':![],'where':{'id':_0x5c7606[_0x4afc('0x58')]['id']},'include':[{'model':db['Pause'],'as':_0x4afc('0x3b')}]},_0x2fe2ae={};_0x2fe2ae['model']=_[_0x4afc('0x43')](db[_0x4afc('0x3d')][_0x4afc('0x3e')]);_0x2fe2ae[_0x4afc('0x42')]=_[_0x4afc('0x43')](_0x5c7606[_0x4afc('0x42')]);_0x2fe2ae[_0x4afc('0x44')]=_[_0x4afc('0x46')](_0x2fe2ae[_0x4afc('0x41')],_0x2fe2ae[_0x4afc('0x42')]);_0x355198[_0x4afc('0x45')]=_[_0x4afc('0x46')](_0x2fe2ae['model'],qs[_0x4afc('0x47')](_0x5c7606[_0x4afc('0x42')][_0x4afc('0x47')]));_0x355198[_0x4afc('0x45')]=_0x355198[_0x4afc('0x45')][_0x4afc('0x48')]?_0x355198[_0x4afc('0x45')]:_0x2fe2ae[_0x4afc('0x41')];if(_0x5c7606[_0x4afc('0x42')][_0x4afc('0x53')]){_0x355198[_0x4afc('0x54')]=[{'all':!![]}];}_0x355198=_[_0x4afc('0x50')]({},_0x355198,_0x5c7606[_0x4afc('0x51')]);return db['OpenchannelAccount'][_0x4afc('0x59')](_0x355198)['then'](handleEntityNotFound(_0x428d78,null))[_0x4afc('0x1f')](respondWithResult(_0x428d78,null))[_0x4afc('0x29')](handleError(_0x428d78,null));};exports[_0x4afc('0x5a')]=function(_0x2d9f3d,_0x518d6f){return db['OpenchannelAccount'][_0x4afc('0x5a')](_0x2d9f3d[_0x4afc('0x5b')],{})['then'](function(_0x40021e){var _0x3af52c=_0x2d9f3d[_0x4afc('0x5c')][_0x4afc('0x5d')]({'plain':!![]});if(!_0x3af52c)throw new Error(_0x4afc('0x5e'));if(_0x3af52c[_0x4afc('0x5f')]===_0x4afc('0x5c')){var _0x13891d=_0x40021e[_0x4afc('0x5d')]({'plain':!![]});var _0x3369a8=_0x4afc('0x36');return db[_0x4afc('0x60')][_0x4afc('0x59')]({'where':{'name':_0x3369a8,'userProfileId':_0x3af52c[_0x4afc('0x61')]},'raw':!![]})['then'](function(_0x42c65e){if(_0x42c65e&&_0x42c65e[_0x4afc('0x62')]===0x0){return db[_0x4afc('0x37')][_0x4afc('0x5a')]({'name':_0x13891d[_0x4afc('0x38')],'resourceId':_0x13891d['id'],'type':_0x42c65e[_0x4afc('0x38')],'sectionId':_0x42c65e['id']},{})[_0x4afc('0x1f')](function(){return _0x40021e;});}else{return _0x40021e;}})['catch'](function(_0x1771e8){logger[_0x4afc('0x25')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1771e8);throw _0x1771e8;});}return _0x40021e;})['then'](respondWithResult(_0x518d6f,0xc9))[_0x4afc('0x29')](handleError(_0x518d6f,null));};exports[_0x4afc('0x34')]=function(_0x2d7066,_0x389040){if(_0x2d7066[_0x4afc('0x5b')]['id']){delete _0x2d7066[_0x4afc('0x5b')]['id'];}return db[_0x4afc('0x3d')][_0x4afc('0x59')]({'where':{'id':_0x2d7066[_0x4afc('0x58')]['id']},'include':[{'model':db[_0x4afc('0x3a')],'as':'mandatoryDispositionPause'}]})['then'](handleEntityNotFound(_0x389040,null))[_0x4afc('0x1f')](saveUpdates(_0x2d7066[_0x4afc('0x5b')],null))['then'](respondWithResult(_0x389040,null))[_0x4afc('0x29')](handleError(_0x389040,null));};exports[_0x4afc('0x35')]=function(_0x5be1a7,_0x56573a){return db[_0x4afc('0x3d')][_0x4afc('0x59')]({'where':{'id':_0x5be1a7[_0x4afc('0x58')]['id']}})['then'](handleEntityNotFound(_0x56573a,null))[_0x4afc('0x1f')](removeEntity(_0x56573a,null))['catch'](handleError(_0x56573a,null));};exports['describe']=function(_0x10e5c6,_0x37b5aa){return db[_0x4afc('0x3d')][_0x4afc('0x63')]()[_0x4afc('0x1f')](respondWithResult(_0x37b5aa,null))[_0x4afc('0x29')](handleError(_0x37b5aa,null));};exports[_0x4afc('0x64')]=function(_0xe05d53,_0x3d1825,_0x4a616e){if(_0xe05d53[_0x4afc('0x5b')]['id']){delete _0xe05d53[_0x4afc('0x5b')]['id'];}return db[_0x4afc('0x3d')]['find']({'where':{'id':_0xe05d53['params']['id']}})['then'](handleEntityNotFound(_0x3d1825,null))[_0x4afc('0x1f')](function(_0x135931){if(_0x135931){_0xe05d53[_0x4afc('0x5b')]['OpenchannelAccountId']=_0x135931['id'];return db[_0x4afc('0x65')]['create'](_0xe05d53['body']);}})['then'](respondWithResult(_0x3d1825,null))[_0x4afc('0x29')](handleError(_0x3d1825,null));};exports[_0x4afc('0x66')]=function(_0x315fc3,_0x4e0fb6,_0x1e56b7){var _0x45cfea={'raw':![],'where':{}};var _0x18ab12={};var _0x5e3e9b={'count':0x0,'rows':[]};return db[_0x4afc('0x3d')][_0x4afc('0x67')]({'where':{'id':_0x315fc3[_0x4afc('0x58')]['id']}})[_0x4afc('0x1f')](handleEntityNotFound(_0x4e0fb6,null))[_0x4afc('0x1f')](function(_0x481263){if(_0x481263){_0x18ab12['model']=_[_0x4afc('0x43')](db[_0x4afc('0x65')][_0x4afc('0x3e')]);_0x18ab12['query']=_[_0x4afc('0x43')](_0x315fc3[_0x4afc('0x42')]);_0x18ab12[_0x4afc('0x44')]=_[_0x4afc('0x46')](_0x18ab12[_0x4afc('0x41')],_0x18ab12['query']);_0x45cfea[_0x4afc('0x45')]=_[_0x4afc('0x46')](_0x18ab12['model'],qs[_0x4afc('0x47')](_0x315fc3[_0x4afc('0x42')][_0x4afc('0x47')]));_0x45cfea['attributes']=_0x45cfea[_0x4afc('0x45')][_0x4afc('0x48')]?_0x45cfea[_0x4afc('0x45')]:_0x18ab12[_0x4afc('0x41')];if(!_0x315fc3[_0x4afc('0x42')][_0x4afc('0x49')](_0x4afc('0x4a'))){_0x45cfea[_0x4afc('0x2d')]=qs['limit'](_0x315fc3[_0x4afc('0x42')]['limit']);_0x45cfea['offset']=qs[_0x4afc('0x2c')](_0x315fc3[_0x4afc('0x42')][_0x4afc('0x2c')]);}_0x45cfea['order']=qs['sort'](_0x315fc3[_0x4afc('0x42')][_0x4afc('0x4c')]);_0x45cfea[_0x4afc('0x4d')]=qs[_0x4afc('0x44')](_[_0x4afc('0x4e')](_0x315fc3[_0x4afc('0x42')],_0x18ab12[_0x4afc('0x44')]));_0x45cfea[_0x4afc('0x4d')][_0x4afc('0x68')]=_0x481263['id'];if(_0x315fc3[_0x4afc('0x42')][_0x4afc('0x4f')]){_0x45cfea[_0x4afc('0x4d')]=_[_0x4afc('0x50')](_0x45cfea[_0x4afc('0x4d')],{'$or':_[_0x4afc('0x3c')](_0x45cfea[_0x4afc('0x45')],function(_0x4f8b24){var _0x2d7d36={};_0x2d7d36[_0x4f8b24]={'$like':'%'+_0x315fc3[_0x4afc('0x42')][_0x4afc('0x4f')]+'%'};return _0x2d7d36;})});}_0x45cfea=_[_0x4afc('0x50')]({},_0x45cfea,_0x315fc3[_0x4afc('0x51')]);return db[_0x4afc('0x65')][_0x4afc('0x52')]({'where':_0x45cfea[_0x4afc('0x4d')]})[_0x4afc('0x1f')](function(_0x4d3da7){_0x5e3e9b[_0x4afc('0x52')]=_0x4d3da7;if(_0x315fc3[_0x4afc('0x42')][_0x4afc('0x53')]){_0x45cfea[_0x4afc('0x54')]=[{'all':!![]}];}return db['Disposition'][_0x4afc('0x55')](_0x45cfea);})[_0x4afc('0x1f')](function(_0x4ce81a){_0x5e3e9b[_0x4afc('0x56')]=_0x4ce81a;return _0x5e3e9b;});}})[_0x4afc('0x1f')](respondWithFilteredResult(_0x4e0fb6,_0x45cfea))[_0x4afc('0x29')](handleError(_0x4e0fb6,null));};exports[_0x4afc('0x69')]=function(_0xf9b232,_0x253d25,_0x2b20ad){return db['OpenchannelAccount'][_0x4afc('0x59')]({'where':{'id':_0xf9b232[_0x4afc('0x58')]['id']}})['then'](handleEntityNotFound(_0x253d25,null))[_0x4afc('0x1f')](function(_0x41a3a9){if(_0x41a3a9){return _0x41a3a9[_0x4afc('0x69')](_0xf9b232['query'][_0x4afc('0x6a')]);}})[_0x4afc('0x1f')](respondWithStatusCode(_0x253d25,null))[_0x4afc('0x29')](handleError(_0x253d25,null));};exports[_0x4afc('0x6b')]=function(_0x4a6f77,_0x1bbe21,_0x29297c){if(_0x4a6f77['body']['id']){delete _0x4a6f77[_0x4afc('0x5b')]['id'];}return db[_0x4afc('0x3d')][_0x4afc('0x59')]({'where':{'id':_0x4a6f77['params']['id']}})['then'](handleEntityNotFound(_0x1bbe21,null))[_0x4afc('0x1f')](function(_0x41116b){if(_0x41116b){_0x4a6f77[_0x4afc('0x5b')][_0x4afc('0x68')]=_0x41116b['id'];return db[_0x4afc('0x6c')][_0x4afc('0x5a')](_0x4a6f77[_0x4afc('0x5b')]);}})[_0x4afc('0x1f')](respondWithResult(_0x1bbe21,null))[_0x4afc('0x29')](handleError(_0x1bbe21,null));};exports[_0x4afc('0x6d')]=function(_0x32a7a3,_0x6d81f2,_0x2775ec){var _0x257d02={'raw':![],'where':{}};var _0x23a491={};var _0x143340={'count':0x0,'rows':[]};return db['OpenchannelAccount'][_0x4afc('0x67')]({'where':{'id':_0x32a7a3[_0x4afc('0x58')]['id']}})['then'](handleEntityNotFound(_0x6d81f2,null))[_0x4afc('0x1f')](function(_0x4d92e6){if(_0x4d92e6){_0x23a491['model']=_[_0x4afc('0x43')](db['CannedAnswer']['rawAttributes']);_0x23a491[_0x4afc('0x42')]=_['keys'](_0x32a7a3[_0x4afc('0x42')]);_0x23a491['filters']=_[_0x4afc('0x46')](_0x23a491[_0x4afc('0x41')],_0x23a491[_0x4afc('0x42')]);_0x257d02[_0x4afc('0x45')]=_[_0x4afc('0x46')](_0x23a491['model'],qs[_0x4afc('0x47')](_0x32a7a3[_0x4afc('0x42')]['fields']));_0x257d02['attributes']=_0x257d02[_0x4afc('0x45')][_0x4afc('0x48')]?_0x257d02[_0x4afc('0x45')]:_0x23a491[_0x4afc('0x41')];if(!_0x32a7a3[_0x4afc('0x42')]['hasOwnProperty'](_0x4afc('0x4a'))){_0x257d02[_0x4afc('0x2d')]=qs[_0x4afc('0x2d')](_0x32a7a3[_0x4afc('0x42')]['limit']);_0x257d02[_0x4afc('0x2c')]=qs['offset'](_0x32a7a3[_0x4afc('0x42')][_0x4afc('0x2c')]);}_0x257d02[_0x4afc('0x4b')]=qs[_0x4afc('0x4c')](_0x32a7a3[_0x4afc('0x42')][_0x4afc('0x4c')]);_0x257d02[_0x4afc('0x4d')]=qs[_0x4afc('0x44')](_[_0x4afc('0x4e')](_0x32a7a3[_0x4afc('0x42')],_0x23a491[_0x4afc('0x44')]));_0x257d02['where'][_0x4afc('0x68')]=_0x4d92e6['id'];if(_0x32a7a3['query'][_0x4afc('0x4f')]){_0x257d02['where']=_['merge'](_0x257d02[_0x4afc('0x4d')],{'$or':_['map'](_0x257d02['attributes'],function(_0x360d43){var _0x489c9d={};_0x489c9d[_0x360d43]={'$like':'%'+_0x32a7a3[_0x4afc('0x42')][_0x4afc('0x4f')]+'%'};return _0x489c9d;})});}_0x257d02=_['merge']({},_0x257d02,_0x32a7a3[_0x4afc('0x51')]);return db[_0x4afc('0x6c')]['count']({'where':_0x257d02[_0x4afc('0x4d')]})[_0x4afc('0x1f')](function(_0x3ec068){_0x143340['count']=_0x3ec068;if(_0x32a7a3[_0x4afc('0x42')][_0x4afc('0x53')]){_0x257d02[_0x4afc('0x54')]=[{'all':!![]}];}return db[_0x4afc('0x6c')][_0x4afc('0x55')](_0x257d02);})[_0x4afc('0x1f')](function(_0x5cc914){_0x143340['rows']=_0x5cc914;return _0x143340;});}})[_0x4afc('0x1f')](respondWithFilteredResult(_0x6d81f2,_0x257d02))[_0x4afc('0x29')](handleError(_0x6d81f2,null));};exports['removeAnswers']=function(_0x28381d,_0x2ff7a1,_0x4f2536){return db[_0x4afc('0x3d')][_0x4afc('0x59')]({'where':{'id':_0x28381d[_0x4afc('0x58')]['id']}})[_0x4afc('0x1f')](handleEntityNotFound(_0x2ff7a1,null))[_0x4afc('0x1f')](function(_0x4b1bbc){if(_0x4b1bbc){return _0x4b1bbc[_0x4afc('0x6e')](_0x28381d[_0x4afc('0x42')][_0x4afc('0x6a')]);}})[_0x4afc('0x1f')](respondWithStatusCode(_0x2ff7a1,null))[_0x4afc('0x29')](handleError(_0x2ff7a1,null));};exports['notify']=function(_0x793480,_0x37f9ea,_0x31b518){var _0x57a878={'body':_0x793480[_0x4afc('0x5b')],'channel':_0x4afc('0x6f')};var _0x5bcfa7=[];var _0x530119=[];var _0x4c27a2={};var _0x1119a9=![];return db[_0x4afc('0x70')]['describe']()[_0x4afc('0x1f')](function(_0x46fe46){if(!_0x46fe46){throw new db['Sequelize'][(_0x4afc('0x71'))](_0x4afc('0x72'));}_0x5bcfa7=_[_0x4afc('0x73')](_[_0x4afc('0x43')](_0x46fe46),[_0x4afc('0x74'),_0x4afc('0x75')]);_0x530119=_[_0x4afc('0x73')](_[_0x4afc('0x43')](_0x46fe46),[_0x4afc('0x74'),'updatedAt',_0x4afc('0x76'),_0x4afc('0x77')]);if(_0x793480[_0x4afc('0x5b')]['id']){delete _0x793480[_0x4afc('0x5b')]['id'];}if(_['isNil'](_0x793480[_0x4afc('0x5b')][_0x4afc('0x78')])){throw new db['Sequelize']['ValidationError']('from\x20is\x20mandatory');}if(_[_0x4afc('0x79')](_0x793480[_0x4afc('0x5b')][_0x4afc('0x5b')])||_0x793480['body'][_0x4afc('0x5b')]===''){throw new db[(_0x4afc('0x7a'))][(_0x4afc('0x71'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x4afc('0x79')](_0x793480['body']['mapKey'])){throw new db[(_0x4afc('0x7a'))][(_0x4afc('0x71'))](_0x4afc('0x7b')+_0x530119);}if(!_['includes'](_0x530119,_0x793480[_0x4afc('0x5b')][_0x4afc('0x7c')])){throw new db[(_0x4afc('0x7a'))][(_0x4afc('0x71'))](_0x4afc('0x7d')+_0x530119);}_0x4c27a2[_0x793480[_0x4afc('0x5b')][_0x4afc('0x7c')]]=_0x793480[_0x4afc('0x5b')][_0x4afc('0x78')];})['then'](function(){return db['OpenchannelAccount'][_0x4afc('0x59')]({'where':{'id':_0x793480[_0x4afc('0x58')]['id']},'include':[{'model':db[_0x4afc('0x7e')],'as':_0x4afc('0x7f'),'include':[{'model':db['CmContact'],'as':_0x4afc('0x80'),'where':_0x4c27a2,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db['OpenchannelApplication'],'as':_0x4afc('0x81')}]});})[_0x4afc('0x1f')](handleEntityNotFound(_0x37f9ea,null))[_0x4afc('0x1f')](function(_0x3e26e9){if(_0x3e26e9&&_0x3e26e9[_0x4afc('0x7f')]){_0x57a878[_0x4afc('0x82')]=_0x3e26e9;_0x57a878[_0x4afc('0x83')]=_0x3e26e9[_0x4afc('0x81')];_0x57a878[_0x4afc('0x84')]=_0x3e26e9[_0x4afc('0x7f')];_0x57a878[_0x4afc('0x83')]=_[_0x4afc('0x85')](_0x57a878[_0x4afc('0x83')],['priority'],[_0x4afc('0x86')]);if(_0x57a878[_0x4afc('0x82')][_0x4afc('0x81')]){delete _0x57a878[_0x4afc('0x82')]['Applications'];}if(_0x57a878[_0x4afc('0x82')][_0x4afc('0x7f')]&&_0x57a878['account'][_0x4afc('0x7f')][_0x4afc('0x80')][_0x4afc('0x48')]){return _0x57a878[_0x4afc('0x82')]['List'][_0x4afc('0x80')][0x0];}var _0x12aadc=_[_0x4afc('0x17')](_0x793480['body'],{'firstName':_0x793480[_0x4afc('0x5b')][_0x4afc('0x78')],'ListId':_0x3e26e9['ListId']});_0x12aadc[_0x793480[_0x4afc('0x5b')]['mapKey']]=_0x793480[_0x4afc('0x5b')][_0x4afc('0x78')];return db[_0x4afc('0x70')][_0x4afc('0x5a')](_0x12aadc,{'fields':_0x5bcfa7,'raw':!![]});}})[_0x4afc('0x1f')](handleEntityNotFound(_0x37f9ea,null))[_0x4afc('0x1f')](function(_0x3aff77){_0x57a878[_0x4afc('0x87')]=_0x3aff77;if(_0x3aff77){var _0x518a6f={'ContactId':_0x3aff77['id'],'OpenchannelAccountId':_0x793480['params']['id'],'from':(_0x3aff77[_0x4afc('0x88')]||'')+'\x20'+(_0x3aff77[_0x4afc('0x89')]||'')};var _0x434314={'OpenchannelAccountId':_0x793480['params']['id'],'closed':![]};if(_0x793480[_0x4afc('0x5b')][_0x4afc('0x8a')]){_0x434314['threadId']=_0x793480[_0x4afc('0x5b')][_0x4afc('0x8a')];return db[_0x4afc('0x8b')]['find']({'where':_0x434314})[_0x4afc('0x1f')](function(_0x43a30c){if(_0x43a30c){return[_0x43a30c,![]];}_0x518a6f[_0x4afc('0x8a')]=_0x793480['body'][_0x4afc('0x8a')];_0x518a6f[_0x4afc('0x8c')]=_0x793480[_0x4afc('0x5b')][_0x4afc('0x8c')];return db[_0x4afc('0x8b')][_0x4afc('0x5a')](_0x518a6f)[_0x4afc('0x1f')](function(_0x2e1881){return[_0x2e1881,!![]];});});}else{_0x434314[_0x4afc('0x8a')]=null;}_0x434314['ContactId']=_0x3aff77['id'];return db[_0x4afc('0x8b')][_0x4afc('0x59')]({'where':_0x434314})[_0x4afc('0x1f')](function(_0x4ee2aa){if(_0x4ee2aa){return[_0x4ee2aa,![]];}return db['OpenchannelInteraction'][_0x4afc('0x5a')](_0x518a6f)[_0x4afc('0x1f')](function(_0x2ddf9f){return[_0x2ddf9f,!![]];});});}})[_0x4afc('0x8d')](function(_0xc8fba2,_0x4118f3){if(_0xc8fba2){_0x1119a9=_0x4118f3;if(!_0x4118f3){var _0x1ef0de={'from':(_0x57a878[_0x4afc('0x87')][_0x4afc('0x88')]||'')+'\x20'+(_0x57a878['contact'][_0x4afc('0x89')]||'')};if(_0x793480[_0x4afc('0x5b')][_0x4afc('0x8a')]&&_0x793480['body'][_0x4afc('0x8e')]&&_0x793480[_0x4afc('0x5b')][_0x4afc('0x8a')]!=_0x793480['body'][_0x4afc('0x8e')]){_0x1ef0de[_0x4afc('0x8a')]=_0x793480[_0x4afc('0x5b')][_0x4afc('0x8e')];}return _0xc8fba2[_0x4afc('0x34')](_0x1ef0de);}else{return _0xc8fba2;}}})[_0x4afc('0x1f')](function(_0x4b9745){_0x57a878[_0x4afc('0x8f')]=_0x4b9745['get']({'plain':!![]});_0x57a878['interaction'][_0x4afc('0x90')]=_0x1119a9;if(_0x57a878['interaction'][_0x4afc('0x90')]){if(_0x57a878[_0x4afc('0x82')][_0x4afc('0x91')]){_0x57a878[_0x4afc('0x83')]['push']({'id':0x0,'priority':_0x57a878[_0x4afc('0x83')]['length']+0x1,'app':_0x4afc('0x92'),'appdata':_0x4afc('0x93'),'interval':'*,*,*,*'});}}return db[_0x4afc('0x94')][_0x4afc('0x5a')]({'body':_0x793480[_0x4afc('0x5b')][_0x4afc('0x5b')],'OpenchannelAccountId':_0x793480['params']['id'],'OpenchannelInteractionId':_0x4b9745['id'],'direction':'in','ContactId':_0x57a878[_0x4afc('0x87')]['id'],'AttachmentId':_0x793480['body'][_0x4afc('0x95')]});})[_0x4afc('0x1f')](function(_0x4c8632){_0x57a878[_0x4afc('0x27')]=_0x4c8632;if(_0x57a878[_0x4afc('0x8f')][_0x4afc('0x96')]){return db[_0x4afc('0x97')]['find']({'attributes':['id',_0x4afc('0x38')],'where':{'id':_0x57a878['interaction'][_0x4afc('0x96')]}})[_0x4afc('0x1f')](function(_0x3377c5){if(_0x3377c5){_0x57a878[_0x4afc('0x83')][_0x4afc('0x98')]({'id':0x0,'priority':0x0,'app':_0x4afc('0x99'),'appdata':_0x3377c5['name']+','+(_0x57a878['account'][_0x4afc('0x9a')]||0xa),'interval':_0x4afc('0x9b')});_0x57a878[_0x4afc('0x9c')]=![];}return respondWithRpcPromise(_0x4afc('0x9d'),_0x4afc('0x9e'),_0x57a878);});}return respondWithRpcPromise(_0x4afc('0x9d'),'startRouting',_0x57a878);})[_0x4afc('0x1f')](function(_0x17771b){respondWithRpcPromise(_0x4afc('0x9f'),_0x4afc('0x9f'),{'event':_0x4afc('0xa0'),'message':_0x17771b},client9002);return _0x17771b;})['then'](respondWithResult(_0x37f9ea,null))[_0x4afc('0x29')](handleError(_0x37f9ea,null));};exports[_0x4afc('0xa1')]=function(_0x2e2f0a,_0x54cbfa,_0x17443e){return db[_0x4afc('0x3d')][_0x4afc('0x67')]({'where':{'id':_0x2e2f0a[_0x4afc('0x58')]['id']}})[_0x4afc('0x1f')](handleEntityNotFound(_0x54cbfa,null))[_0x4afc('0x1f')](function(_0x164b69){if(_0x164b69){return db[_0x4afc('0xa2')]['transaction'](function(_0x20ba44){return db[_0x4afc('0xa3')][_0x4afc('0x35')]({'where':{'OpenchannelAccountId':_0x2e2f0a[_0x4afc('0x58')]['id']},'transaction':_0x20ba44})[_0x4afc('0x1f')](function(_0xc36399){var _0x23a727=_['map'](_0x2e2f0a[_0x4afc('0x5b')],function(_0x45e4f4){_0x45e4f4[_0x4afc('0x68')]=_0x2e2f0a[_0x4afc('0x58')]['id'];return _0x45e4f4;});return db[_0x4afc('0xa3')][_0x4afc('0xa4')](_0x23a727,{'transaction':_0x20ba44});});})[_0x4afc('0x1f')](function(){return db['OpenchannelApplication']['findAndCountAll']({'where':{'OpenchannelAccountId':_0x2e2f0a[_0x4afc('0x58')]['id']},'order':'priority'});});}})[_0x4afc('0x1f')](respondWithResult(_0x54cbfa,null))[_0x4afc('0x29')](handleError(_0x54cbfa,null));};exports[_0x4afc('0xa5')]=function(_0x51dd4d,_0x75a628,_0x1ea1cb){var _0x1033a8={};var _0x31757b={};var _0x4a62e1;var _0x481418;return db[_0x4afc('0x3d')][_0x4afc('0x67')]({'where':{'id':_0x51dd4d[_0x4afc('0x58')]['id']}})['then'](handleEntityNotFound(_0x75a628,null))[_0x4afc('0x1f')](function(_0x48830a){if(_0x48830a){_0x4a62e1=_0x48830a;_0x31757b[_0x4afc('0x41')]=_['keys'](db[_0x4afc('0xa3')]['rawAttributes']);_0x31757b[_0x4afc('0x42')]=_['keys'](_0x51dd4d[_0x4afc('0x42')]);_0x31757b[_0x4afc('0x44')]=_[_0x4afc('0x46')](_0x31757b['model'],_0x31757b[_0x4afc('0x42')]);_0x1033a8['attributes']=_[_0x4afc('0x46')](_0x31757b['model'],qs[_0x4afc('0x47')](_0x51dd4d[_0x4afc('0x42')]['fields']));_0x1033a8[_0x4afc('0x45')]=_0x1033a8['attributes']['length']?_0x1033a8[_0x4afc('0x45')]:_0x31757b[_0x4afc('0x41')];_0x1033a8[_0x4afc('0x4b')]=qs[_0x4afc('0x4c')](_0x51dd4d[_0x4afc('0x42')][_0x4afc('0x4c')]);_0x1033a8[_0x4afc('0x4d')]=qs[_0x4afc('0x44')](_[_0x4afc('0x4e')](_0x51dd4d['query'],_0x31757b[_0x4afc('0x44')]));if(_0x51dd4d[_0x4afc('0x42')][_0x4afc('0x4f')]){_0x1033a8[_0x4afc('0x4d')]=_[_0x4afc('0x50')](_0x1033a8['where'],{'$or':_[_0x4afc('0x3c')](_0x1033a8['attributes'],function(_0x399644){var _0x14c79c={};_0x14c79c[_0x399644]={'$like':'%'+_0x51dd4d['query'][_0x4afc('0x4f')]+'%'};return _0x14c79c;})});}_0x1033a8=_[_0x4afc('0x50')]({},_0x1033a8,_0x51dd4d['options']);return _0x4a62e1[_0x4afc('0xa5')](_0x1033a8);}})[_0x4afc('0x1f')](function(_0xffddad){if(_0xffddad){_0x481418=_0xffddad['length'];if(!_0x51dd4d['query'][_0x4afc('0x49')](_0x4afc('0x4a'))){_0x1033a8[_0x4afc('0x2d')]=qs[_0x4afc('0x2d')](_0x51dd4d[_0x4afc('0x42')][_0x4afc('0x2d')]);_0x1033a8[_0x4afc('0x2c')]=qs['offset'](_0x51dd4d[_0x4afc('0x42')][_0x4afc('0x2c')]);}return _0x4a62e1[_0x4afc('0xa5')](_0x1033a8);}})[_0x4afc('0x1f')](function(_0x1a3f6a){if(_0x1a3f6a){return _0x1a3f6a?{'count':_0x481418,'rows':_0x1a3f6a}:null;}})[_0x4afc('0x1f')](respondWithResult(_0x75a628,null))[_0x4afc('0x29')](handleError(_0x75a628,null));};exports['getInteractions']=function(_0xc0ff4e,_0x5a492d,_0x2177a3){var _0x21a41f={'raw':![],'where':{}};var _0xbe1818={};var _0x354f3a={'count':0x0,'rows':[]};return db[_0x4afc('0x3d')]['findOne']({'where':{'id':_0xc0ff4e['params']['id']}})[_0x4afc('0x1f')](handleEntityNotFound(_0x5a492d,null))['then'](function(_0x5d8cb3){if(_0x5d8cb3){_0xbe1818[_0x4afc('0x41')]=_[_0x4afc('0x43')](db['OpenchannelInteraction'][_0x4afc('0x3e')]);_0xbe1818[_0x4afc('0x42')]=_['keys'](_0xc0ff4e[_0x4afc('0x42')]);_0xbe1818[_0x4afc('0x44')]=_[_0x4afc('0x46')](_0xbe1818[_0x4afc('0x41')],_0xbe1818[_0x4afc('0x42')]);_0x21a41f['attributes']=_['intersection'](_0xbe1818[_0x4afc('0x41')],qs[_0x4afc('0x47')](_0xc0ff4e[_0x4afc('0x42')]['fields']));_0x21a41f['attributes']=_0x21a41f['attributes']['length']?_0x21a41f[_0x4afc('0x45')]:_0xbe1818[_0x4afc('0x41')];if(!_0xc0ff4e[_0x4afc('0x42')][_0x4afc('0x49')]('nolimit')){_0x21a41f[_0x4afc('0x2d')]=qs[_0x4afc('0x2d')](_0xc0ff4e[_0x4afc('0x42')][_0x4afc('0x2d')]);_0x21a41f['offset']=qs[_0x4afc('0x2c')](_0xc0ff4e[_0x4afc('0x42')][_0x4afc('0x2c')]);}_0x21a41f[_0x4afc('0x4b')]=qs[_0x4afc('0x4c')](_0xc0ff4e[_0x4afc('0x42')]['sort']);_0x21a41f[_0x4afc('0x4d')]=qs[_0x4afc('0x44')](_['pick'](_0xc0ff4e[_0x4afc('0x42')],_0xbe1818['filters']));_0x21a41f['where'][_0x4afc('0x68')]=_0x5d8cb3['id'];if(_0xc0ff4e[_0x4afc('0x42')][_0x4afc('0x4f')]){_0x21a41f[_0x4afc('0x4d')]=_[_0x4afc('0x50')](_0x21a41f[_0x4afc('0x4d')],{'$or':_[_0x4afc('0x3c')](_0x21a41f['attributes'],function(_0x253e57){var _0x36f6ad={};_0x36f6ad[_0x253e57]={'$like':'%'+_0xc0ff4e['query'][_0x4afc('0x4f')]+'%'};return _0x36f6ad;})});}_0x21a41f=_[_0x4afc('0x50')]({},_0x21a41f,_0xc0ff4e['options']);return db[_0x4afc('0x8b')][_0x4afc('0x52')]({'where':_0x21a41f[_0x4afc('0x4d')]})['then'](function(_0x409be5){_0x354f3a[_0x4afc('0x52')]=_0x409be5;if(_0xc0ff4e[_0x4afc('0x42')]['includeAll']){_0x21a41f['include']=[{'model':db[_0x4afc('0x70')],'as':'Contact','required':![]},{'model':db[_0x4afc('0x97')],'as':_0x4afc('0xa6'),'attributes':[_0x4afc('0x38'),'fullname','internal'],'required':![]},{'model':db[_0x4afc('0xa7')],'as':_0x4afc('0xa8'),'attributes':['id',_0x4afc('0x38'),_0x4afc('0xa9')],'where':_0xc0ff4e[_0x4afc('0x42')][_0x4afc('0xaa')]?{'id':_0xc0ff4e['query'][_0x4afc('0xaa')]}:undefined,'required':_0xc0ff4e[_0x4afc('0x42')][_0x4afc('0xaa')]?!![]:![]}];}return db[_0x4afc('0x8b')][_0x4afc('0x55')](_0x21a41f);})['then'](function(_0x1da8c0){_0x354f3a[_0x4afc('0x56')]=_0x1da8c0;return _0x354f3a;});}})[_0x4afc('0x1f')](respondWithFilteredResult(_0x5a492d,_0x21a41f))['catch'](handleError(_0x5a492d,null));};exports[_0x4afc('0xab')]=function(_0x133d22,_0x5256df,_0x537fae){return db[_0x4afc('0x3d')][_0x4afc('0x59')]({'where':{'id':_0x133d22[_0x4afc('0x58')]['id']}})[_0x4afc('0x1f')](handleEntityNotFound(_0x5256df,null))[_0x4afc('0x1f')](function(_0x4f68fa){if(_0x4f68fa){return _0x4f68fa[_0x4afc('0xab')](_0x133d22[_0x4afc('0x5b')]['ids'],_[_0x4afc('0xac')](_0x133d22[_0x4afc('0x5b')],['ids','id'])||{})[_0x4afc('0x8d')](function(_0x17940a){for(var _0x3b3226=0x0;_0x3b3226<_0x133d22[_0x4afc('0x5b')][_0x4afc('0x6a')][_0x4afc('0x48')];_0x3b3226+=0x1){socket['emit'](_0x4afc('0xad'),{'UserId':_0x133d22[_0x4afc('0x5b')][_0x4afc('0x6a')][_0x3b3226],'OpenchannelAccountId':_0x133d22[_0x4afc('0x58')]['id']});}return _0x17940a;});}})['then'](respondWithResult(_0x5256df,null))[_0x4afc('0x29')](handleError(_0x5256df,null));};exports[_0x4afc('0xae')]=function(_0x3cac2f,_0x127814,_0x49ee03){return db[_0x4afc('0x3d')][_0x4afc('0x59')]({'where':{'id':_0x3cac2f[_0x4afc('0x58')]['id']}})[_0x4afc('0x1f')](handleEntityNotFound(_0x127814,null))[_0x4afc('0x1f')](function(_0x338de8){if(_0x338de8){return _0x338de8[_0x4afc('0xae')](_0x3cac2f['query']['ids'])['then'](function(){if(_[_0x4afc('0xaf')](_0x3cac2f['query'][_0x4afc('0x6a')])){for(var _0x4e05af=0x0;_0x4e05af<_0x3cac2f[_0x4afc('0x42')][_0x4afc('0x6a')][_0x4afc('0x48')];_0x4e05af+=0x1){socket['emit'](_0x4afc('0xb0'),{'UserId':Number(_0x3cac2f[_0x4afc('0x42')][_0x4afc('0x6a')][_0x4e05af]),'OpenchannelAccountId':Number(_0x3cac2f[_0x4afc('0x58')]['id'])});}}else{socket['emit'](_0x4afc('0xb0'),{'UserId':Number(_0x3cac2f[_0x4afc('0x42')][_0x4afc('0x6a')]),'OpenchannelAccountId':Number(_0x3cac2f['params']['id'])});}});}})[_0x4afc('0x1f')](respondWithStatusCode(_0x127814,null))[_0x4afc('0x29')](handleError(_0x127814,null));};exports['getAgents']=function(_0x43f64e,_0x2e041a,_0x6ad393){var _0x1d6bd2={};var _0x2864fa={};var _0x48d0ee;var _0x563172;return db[_0x4afc('0x3d')][_0x4afc('0x67')]({'where':{'id':_0x43f64e[_0x4afc('0x58')]['id']}})[_0x4afc('0x1f')](handleEntityNotFound(_0x2e041a,null))[_0x4afc('0x1f')](function(_0x5152ab){if(_0x5152ab){_0x48d0ee=_0x5152ab;_0x2864fa[_0x4afc('0x41')]=_[_0x4afc('0x43')](db[_0x4afc('0x97')][_0x4afc('0x3e')]);_0x2864fa['query']=_[_0x4afc('0x43')](_0x43f64e[_0x4afc('0x42')]);_0x2864fa[_0x4afc('0x44')]=_[_0x4afc('0x46')](_0x2864fa[_0x4afc('0x41')],_0x2864fa[_0x4afc('0x42')]);_0x1d6bd2[_0x4afc('0x45')]=_['intersection'](_0x2864fa[_0x4afc('0x41')],qs[_0x4afc('0x47')](_0x43f64e[_0x4afc('0x42')]['fields']));_0x1d6bd2['attributes']=_0x1d6bd2['attributes']['length']?_0x1d6bd2['attributes']:_0x2864fa[_0x4afc('0x41')];_0x1d6bd2['order']=qs[_0x4afc('0x4c')](_0x43f64e[_0x4afc('0x42')][_0x4afc('0x4c')]);_0x1d6bd2['where']=qs[_0x4afc('0x44')](_[_0x4afc('0x4e')](_0x43f64e[_0x4afc('0x42')],_0x2864fa[_0x4afc('0x44')]));if(_0x43f64e[_0x4afc('0x42')][_0x4afc('0x4f')]){_0x1d6bd2[_0x4afc('0x4d')]=_[_0x4afc('0x50')](_0x1d6bd2['where'],{'$or':_[_0x4afc('0x3c')](_0x1d6bd2[_0x4afc('0x45')],function(_0x5f3751){var _0x2d7590={};_0x2d7590[_0x5f3751]={'$like':'%'+_0x43f64e[_0x4afc('0x42')]['filter']+'%'};return _0x2d7590;})});}_0x1d6bd2=_['merge']({},_0x1d6bd2,_0x43f64e[_0x4afc('0x51')]);return _0x48d0ee[_0x4afc('0xb1')](_0x1d6bd2);}})[_0x4afc('0x1f')](function(_0x444e1a){if(_0x444e1a){_0x563172=_0x444e1a['length'];if(!_0x43f64e[_0x4afc('0x42')][_0x4afc('0x49')](_0x4afc('0x4a'))){_0x1d6bd2[_0x4afc('0x2d')]=qs['limit'](_0x43f64e['query']['limit']);_0x1d6bd2[_0x4afc('0x2c')]=qs[_0x4afc('0x2c')](_0x43f64e['query'][_0x4afc('0x2c')]);}return _0x48d0ee['getAgents'](_0x1d6bd2);}})['then'](function(_0x319692){if(_0x319692){return _0x319692?{'count':_0x563172,'rows':_0x319692}:null;}})['then'](respondWithResult(_0x2e041a,null))[_0x4afc('0x29')](handleError(_0x2e041a,null));};exports[_0x4afc('0xb2')]=function(_0x33ee71,_0x172a8a,_0x316e76){var _0x485f68,_0x39c4b5,_0x5bb7b9;if(_[_0x4afc('0x79')](_0x33ee71[_0x4afc('0x5b')][_0x4afc('0x5b')])||_0x33ee71[_0x4afc('0x5b')][_0x4afc('0x5b')]===''){throw new db['Sequelize'][(_0x4afc('0x71'))](_0x4afc('0xb3'));}if(_[_0x4afc('0x79')](_0x33ee71[_0x4afc('0x5b')]['to'])){}_0x485f68=_0x33ee71['body']['to'];return db[_0x4afc('0x3d')][_0x4afc('0x67')]({'where':{'id':_0x33ee71['params']['id']}})[_0x4afc('0x1f')](handleEntityNotFound(_0x172a8a,null))['then'](function(_0x588d22){if(_0x588d22){return db[_0x4afc('0x3d')][_0x4afc('0x59')]({'where':{'id':_0x588d22['id']},'include':[{'model':db[_0x4afc('0x7e')],'as':_0x4afc('0x7f'),'include':[{'model':db[_0x4afc('0x70')],'as':_0x4afc('0x80'),'where':{[_0x588d22[_0x4afc('0x7c')]]:_0x485f68},'limit':0x1,'order':[[_0x4afc('0x75'),_0x4afc('0xb4')]]}]}]})[_0x4afc('0x1f')](handleEntityNotFound(_0x172a8a,null))['then'](function(_0x46d574){if(_0x46d574&&_0x46d574[_0x4afc('0x7f')]){_0x39c4b5=_0x46d574[_0x4afc('0x5d')]({'plain':!![]});if(_0x39c4b5[_0x4afc('0x7f')]&&_0x39c4b5['List'][_0x4afc('0x80')][_0x4afc('0x48')]){return _0x39c4b5[_0x4afc('0x7f')][_0x4afc('0x80')][0x0];}return db[_0x4afc('0x70')][_0x4afc('0x5a')](_[_0x4afc('0x17')](_0x33ee71['body'],{'firstName':_0x485f68,[_0x46d574['mapKey']]:_0x485f68,'phone':_0x485f68,'ListId':_0x39c4b5['ListId']}));}})['then'](handleEntityNotFound(_0x172a8a,null))[_0x4afc('0x1f')](function(_0x3af1d3){if(_0x3af1d3){_0x5bb7b9=_0x3af1d3;return db[_0x4afc('0x8b')][_0x4afc('0x59')]({'where':{'ContactId':_0x5bb7b9['id'],'closed':![],'OpenchannelAccountId':_0x39c4b5['id']}})[_0x4afc('0x1f')](function(_0x938d9a){if(_0x938d9a){return[_0x938d9a,![]];}return db[_0x4afc('0x8b')]['create']({'UserId':_0x33ee71[_0x4afc('0x5c')]['id'],'ContactId':_0x5bb7b9['id'],'OpenchannelAccountId':_0x39c4b5['id'],'lastMsgDirection':_0x4afc('0xb5'),'Messages':[_[_0x4afc('0x50')](_0x33ee71[_0x4afc('0x5b')],{'read':![],'body':_0x33ee71[_0x4afc('0x5b')][_0x4afc('0x5b')],'OpenchannelAccountId':_0x39c4b5['id'],'UserId':_0x33ee71[_0x4afc('0x5c')]['id'],'ContactId':_0x5bb7b9['id']})]},{'include':[{'model':db['OpenchannelMessage'],'as':'Messages'}]})[_0x4afc('0x1f')](function(_0x2fb006){return[_0x2fb006,!![]];});});}})[_0x4afc('0x8d')](function(_0xa1b979,_0xef44ed){if(_0xef44ed){return _0xa1b979;}return db[_0x4afc('0x94')][_0x4afc('0x5a')](_[_0x4afc('0x50')](_0x33ee71[_0x4afc('0x5b')],{'read':![],'body':_0x33ee71[_0x4afc('0x5b')]['body'],'OpenchannelAccountId':_0x39c4b5['id'],'OpenchannelInteractionId':_0xa1b979['id'],'UserId':_0x33ee71[_0x4afc('0x5c')]['id'],'ContactId':_0x5bb7b9['id']}))[_0x4afc('0x1f')](function(_0x394182){_0xa1b979[_0x4afc('0xb6')][_0x4afc('0xb7')]=[];_0xa1b979[_0x4afc('0xb6')][_0x4afc('0xb7')][_0x4afc('0xb8')](_0x394182[_0x4afc('0xb6')]);return _0xa1b979;});});}})[_0x4afc('0x1f')](respondWithResult(_0x172a8a,null))[_0x4afc('0x29')](handleError(_0x172a8a,null));};
\ No newline at end of file
+var _0xe8a4=['catch','sendStatus','status','offset','undefined','limit','apply','reject','save','update','get','end','send','index','OpenchannelAccount','fieldName','type','model','map','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','options','count','includeAll','include','show','params','Pause','rawAttributes','filters','length','merge','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','OpenchannelAccounts','UserProfileSection','find','userProfileId','autoAssociation','name','mandatoryDispositionPause','destroy','describe','OpenchannelAccountId','Disposition','getDispositions','findOne','findAll','rows','removeDispositions','addAnswer','CannedAnswer','removeAnswers','ids','notify','openchannel','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','isNil','from','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','Contacts','DESC','OpenchannelApplication','Applications','account','list','applications','orderBy','asc','defaults','ListId','firstName','lastName','threadId','externalUrl','OpenchannelInteraction','spread','contact','messageId','interaction','created','autoclose','push','close','unmanaged','*,*,*,*','OpenchannelMessage','AttachmentId','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','addApplications','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','bulkCreate','finally','json','getApplications','Contact','User','Owner','fullname','Tag','Tags','color','tag','addAgents','omit','emit','userOpenchannelAccount:save','removeAgents','userOpenchannelAccount:remove','getAgents','body\x20is\x20mandatory\x20and\x20not\x20empty','CmList','out','dataValues','Messages','eml-format','zip-dir','request-promise','moment','bluebird','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','socket.io-emitter','./openchannelAccount.socket','jayson/promise','http','client','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','message'];(function(_0xd08da0,_0x30b2a1){var _0x56f585=function(_0x3c63ae){while(--_0x3c63ae){_0xd08da0['push'](_0xd08da0['shift']());}};_0x56f585(++_0x30b2a1);}(_0xe8a4,0x158));var _0x4e8a=function(_0x25bea7,_0x49ab45){_0x25bea7=_0x25bea7-0x0;var _0x175952=_0xe8a4[_0x25bea7];return _0x175952;};'use strict';var emlformat=require(_0x4e8a('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x4e8a('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x4e8a('0x2'));var moment=require(_0x4e8a('0x3'));var BPromise=require(_0x4e8a('0x4'));var Mustache=require('mustache');var util=require(_0x4e8a('0x5'));var path=require(_0x4e8a('0x6'));var sox=require('sox');var csv=require(_0x4e8a('0x7'));var ejs=require(_0x4e8a('0x8'));var fs=require('fs');var fs_extra=require(_0x4e8a('0x9'));var _=require(_0x4e8a('0xa'));var squel=require(_0x4e8a('0xb'));var crypto=require(_0x4e8a('0xc'));var jsforce=require(_0x4e8a('0xd'));var deskjs=require(_0x4e8a('0xe'));var toCsv=require(_0x4e8a('0x7'));var querystring=require(_0x4e8a('0xf'));var Papa=require('papaparse');var Redis=require(_0x4e8a('0x10'));var authService=require(_0x4e8a('0x11'));var qs=require(_0x4e8a('0x12'));var as=require(_0x4e8a('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x4e8a('0x14'))(_0x4e8a('0x15'));var utils=require('../../config/utils');var config=require(_0x4e8a('0x16'));var licenseUtil=require(_0x4e8a('0x17'));var db=require(_0x4e8a('0x18'))['db'];config[_0x4e8a('0x19')]=_['defaults'](config[_0x4e8a('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x4e8a('0x1a'))(new Redis(config[_0x4e8a('0x19')]));require(_0x4e8a('0x1b'))['register'](socket);var jayson=require(_0x4e8a('0x1c'));var client=jayson['client'][_0x4e8a('0x1d')]({'port':0x232c});var client9002=jayson[_0x4e8a('0x1e')][_0x4e8a('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x4e2a54,_0x458235,_0x16af6f,_0x435200){return new BPromise(function(_0x13eb23,_0x5460e8){var _0x2390e4=_0x435200||client;return _0x2390e4['request'](_0x4e2a54,_0x16af6f)[_0x4e8a('0x1f')](function(_0x121a60){logger[_0x4e8a('0x20')](_0x4e8a('0x21'),_0x458235,_0x4e8a('0x22'));logger[_0x4e8a('0x23')](_0x4e8a('0x24'),_0x458235,_0x4e8a('0x22'),JSON[_0x4e8a('0x25')](_0x121a60));if(_0x121a60['error']){if(_0x121a60['error']['code']===0x1f4){logger[_0x4e8a('0x26')](_0x4e8a('0x21'),_0x458235,_0x121a60[_0x4e8a('0x26')][_0x4e8a('0x27')]);return _0x5460e8(_0x121a60[_0x4e8a('0x26')]['message']);}logger['error']('OpenchannelAccount,\x20%s,\x20%s',_0x458235,_0x121a60['error'][_0x4e8a('0x27')]);return _0x13eb23(_0x121a60[_0x4e8a('0x26')][_0x4e8a('0x27')]);}else{logger['info'](_0x4e8a('0x21'),_0x458235,_0x4e8a('0x22'));_0x13eb23(_0x121a60['result'][_0x4e8a('0x27')]);}})[_0x4e8a('0x28')](function(_0x50a80a){logger[_0x4e8a('0x26')]('OpenchannelAccount,\x20%s,\x20%s',_0x458235,_0x50a80a);_0x5460e8(_0x50a80a);});});}function respondWithStatusCode(_0x3f88c2,_0x34b531){_0x34b531=_0x34b531||0xcc;return function(_0x3a9d32){if(_0x3a9d32){return _0x3f88c2[_0x4e8a('0x29')](_0x34b531);}return _0x3f88c2['status'](_0x34b531)['end']();};}function respondWithResult(_0x27a048,_0x31bbe1){_0x31bbe1=_0x31bbe1||0xc8;return function(_0x5a71e3){if(_0x5a71e3){return _0x27a048[_0x4e8a('0x2a')](_0x31bbe1)['json'](_0x5a71e3);}};}function respondWithFilteredResult(_0x1d22d5,_0x5766c5){return function(_0x2d1e63){if(_0x2d1e63){var _0x3f53a9=typeof _0x5766c5[_0x4e8a('0x2b')]===_0x4e8a('0x2c')&&typeof _0x5766c5[_0x4e8a('0x2d')]==='undefined';var _0x56efc4=_0x2d1e63['count'];var _0x3e450b=_0x3f53a9?0x0:_0x5766c5[_0x4e8a('0x2b')];var _0x2a3703=_0x3f53a9?_0x2d1e63['count']:_0x5766c5[_0x4e8a('0x2b')]+_0x5766c5['limit'];var _0x200ca8;if(_0x2a3703>=_0x56efc4){_0x2a3703=_0x56efc4;_0x200ca8=0xc8;}else{_0x200ca8=0xce;}_0x1d22d5['status'](_0x200ca8);return _0x1d22d5['set']('Content-Range',_0x3e450b+'-'+_0x2a3703+'/'+_0x56efc4)['json'](_0x2d1e63);}return null;};}function patchUpdates(_0x2be564){return function(_0x3647df){try{jsonpatch[_0x4e8a('0x2e')](_0x3647df,_0x2be564,!![]);}catch(_0x9331dd){return BPromise[_0x4e8a('0x2f')](_0x9331dd);}return _0x3647df[_0x4e8a('0x30')]();};}function saveUpdates(_0x382b16,_0x287d9c){return function(_0x5224be){if(_0x5224be){return _0x5224be[_0x4e8a('0x31')](_0x382b16)['then'](function(_0x3d9dd2){return _0x3d9dd2;});}return null;};}function removeEntity(_0x254dfb,_0x52ef06){return function(_0x3fd5b9){if(_0x3fd5b9){return _0x3fd5b9['destroy']()[_0x4e8a('0x1f')](function(){var _0x21af7d=_0x3fd5b9[_0x4e8a('0x32')]({'plain':!![]});var _0x44d8e7='OpenchannelAccounts';return db['UserProfileResource']['destroy']({'where':{'type':_0x44d8e7,'resourceId':_0x21af7d['id']}})[_0x4e8a('0x1f')](function(){return _0x3fd5b9;});})['then'](function(){_0x254dfb[_0x4e8a('0x2a')](0xcc)[_0x4e8a('0x33')]();});}};}function handleEntityNotFound(_0x37ca6e,_0x5564df){return function(_0x3c74de){if(!_0x3c74de){_0x37ca6e[_0x4e8a('0x29')](0x194);}return _0x3c74de;};}function handleError(_0x318d14,_0x297dfb){_0x297dfb=_0x297dfb||0x1f4;return function(_0x39bd2d){logger[_0x4e8a('0x26')](_0x39bd2d['stack']);if(_0x39bd2d['name']){delete _0x39bd2d['name'];}_0x318d14[_0x4e8a('0x2a')](_0x297dfb)[_0x4e8a('0x34')](_0x39bd2d);};}exports[_0x4e8a('0x35')]=function(_0x38538d,_0x274d4c){var _0xb4a961={'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x2b9f0f={},_0x135375={'count':0x0,'rows':[]};var _0x5b2b6c=_['map'](db[_0x4e8a('0x36')]['rawAttributes'],function(_0x31e3f1){return{'name':_0x31e3f1[_0x4e8a('0x37')],'type':_0x31e3f1[_0x4e8a('0x38')]['key']};});_0x2b9f0f[_0x4e8a('0x39')]=_[_0x4e8a('0x3a')](_0x5b2b6c,'name');_0x2b9f0f[_0x4e8a('0x3b')]=_[_0x4e8a('0x3c')](_0x38538d['query']);_0x2b9f0f['filters']=_[_0x4e8a('0x3d')](_0x2b9f0f[_0x4e8a('0x39')],_0x2b9f0f['query']);_0xb4a961[_0x4e8a('0x3e')]=_[_0x4e8a('0x3d')](_0x2b9f0f[_0x4e8a('0x39')],qs[_0x4e8a('0x3f')](_0x38538d[_0x4e8a('0x3b')][_0x4e8a('0x3f')]));_0xb4a961['attributes']=_0xb4a961[_0x4e8a('0x3e')]['length']?_0xb4a961[_0x4e8a('0x3e')]:_0x2b9f0f[_0x4e8a('0x39')];if(!_0x38538d['query'][_0x4e8a('0x40')](_0x4e8a('0x41'))){_0xb4a961[_0x4e8a('0x2d')]=qs[_0x4e8a('0x2d')](_0x38538d[_0x4e8a('0x3b')][_0x4e8a('0x2d')]);_0xb4a961[_0x4e8a('0x2b')]=qs['offset'](_0x38538d[_0x4e8a('0x3b')]['offset']);}_0xb4a961[_0x4e8a('0x42')]=qs['sort'](_0x38538d[_0x4e8a('0x3b')][_0x4e8a('0x43')]);_0xb4a961[_0x4e8a('0x44')]=qs['filters'](_[_0x4e8a('0x45')](_0x38538d['query'],_0x2b9f0f['filters']),_0x5b2b6c);if(_0x38538d[_0x4e8a('0x3b')][_0x4e8a('0x46')]){_0xb4a961['where']=_['merge'](_0xb4a961['where'],{'$or':_[_0x4e8a('0x3a')](_0x5b2b6c,function(_0x41e8ce){if(_0x41e8ce[_0x4e8a('0x38')]!==_0x4e8a('0x47')){var _0x46d40c={};_0x46d40c[_0x41e8ce['name']]={'$like':'%'+_0x38538d[_0x4e8a('0x3b')]['filter']+'%'};return _0x46d40c;}})});}_0xb4a961=_['merge']({},_0xb4a961,_0x38538d[_0x4e8a('0x48')]);var _0xfeb06a={'where':_0xb4a961[_0x4e8a('0x44')]};return db[_0x4e8a('0x36')][_0x4e8a('0x49')](_0xfeb06a)[_0x4e8a('0x1f')](function(_0x6610ef){_0x135375[_0x4e8a('0x49')]=_0x6610ef;if(_0x38538d[_0x4e8a('0x3b')][_0x4e8a('0x4a')]){_0xb4a961[_0x4e8a('0x4b')]=[{'all':!![]}];}return db[_0x4e8a('0x36')]['findAll'](_0xb4a961);})[_0x4e8a('0x1f')](function(_0x3cb1ee){_0x135375['rows']=_0x3cb1ee;return _0x135375;})[_0x4e8a('0x1f')](respondWithFilteredResult(_0x274d4c,_0xb4a961))[_0x4e8a('0x28')](handleError(_0x274d4c,null));};exports[_0x4e8a('0x4c')]=function(_0x5d8d31,_0x27d7e4){var _0x3e6302={'raw':![],'where':{'id':_0x5d8d31[_0x4e8a('0x4d')]['id']},'include':[{'model':db[_0x4e8a('0x4e')],'as':'mandatoryDispositionPause'}]},_0x5071d8={};_0x5071d8[_0x4e8a('0x39')]=_[_0x4e8a('0x3c')](db[_0x4e8a('0x36')][_0x4e8a('0x4f')]);_0x5071d8[_0x4e8a('0x3b')]=_[_0x4e8a('0x3c')](_0x5d8d31['query']);_0x5071d8[_0x4e8a('0x50')]=_[_0x4e8a('0x3d')](_0x5071d8[_0x4e8a('0x39')],_0x5071d8['query']);_0x3e6302[_0x4e8a('0x3e')]=_[_0x4e8a('0x3d')](_0x5071d8[_0x4e8a('0x39')],qs[_0x4e8a('0x3f')](_0x5d8d31[_0x4e8a('0x3b')][_0x4e8a('0x3f')]));_0x3e6302[_0x4e8a('0x3e')]=_0x3e6302['attributes'][_0x4e8a('0x51')]?_0x3e6302[_0x4e8a('0x3e')]:_0x5071d8[_0x4e8a('0x39')];if(_0x5d8d31['query']['includeAll']){_0x3e6302['include']=[{'all':!![]}];}_0x3e6302=_[_0x4e8a('0x52')]({},_0x3e6302,_0x5d8d31[_0x4e8a('0x48')]);return db[_0x4e8a('0x36')]['find'](_0x3e6302)['then'](handleEntityNotFound(_0x27d7e4,null))[_0x4e8a('0x1f')](respondWithResult(_0x27d7e4,null))['catch'](handleError(_0x27d7e4,null));};exports['create']=function(_0x2bca57,_0x1e3672){return db['OpenchannelAccount'][_0x4e8a('0x53')](_0x2bca57[_0x4e8a('0x54')],{})[_0x4e8a('0x1f')](function(_0x2e493e){var _0xba9887=_0x2bca57[_0x4e8a('0x55')]['get']({'plain':!![]});if(!_0xba9887)throw new Error(_0x4e8a('0x56'));if(_0xba9887[_0x4e8a('0x57')]===_0x4e8a('0x55')){var _0x48f01f=_0x2e493e['get']({'plain':!![]});var _0x3f04ce=_0x4e8a('0x58');return db[_0x4e8a('0x59')][_0x4e8a('0x5a')]({'where':{'name':_0x3f04ce,'userProfileId':_0xba9887[_0x4e8a('0x5b')]},'raw':!![]})[_0x4e8a('0x1f')](function(_0x4b5831){if(_0x4b5831&&_0x4b5831[_0x4e8a('0x5c')]===0x0){return db['UserProfileResource'][_0x4e8a('0x53')]({'name':_0x48f01f[_0x4e8a('0x5d')],'resourceId':_0x48f01f['id'],'type':_0x4b5831[_0x4e8a('0x5d')],'sectionId':_0x4b5831['id']},{})['then'](function(){return _0x2e493e;});}else{return _0x2e493e;}})['catch'](function(_0xba5aaa){logger[_0x4e8a('0x26')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xba5aaa);throw _0xba5aaa;});}return _0x2e493e;})[_0x4e8a('0x1f')](respondWithResult(_0x1e3672,0xc9))[_0x4e8a('0x28')](handleError(_0x1e3672,null));};exports[_0x4e8a('0x31')]=function(_0x4b418b,_0x5a9873){if(_0x4b418b['body']['id']){delete _0x4b418b['body']['id'];}return db['OpenchannelAccount']['find']({'where':{'id':_0x4b418b[_0x4e8a('0x4d')]['id']},'include':[{'model':db[_0x4e8a('0x4e')],'as':_0x4e8a('0x5e')}]})[_0x4e8a('0x1f')](handleEntityNotFound(_0x5a9873,null))['then'](saveUpdates(_0x4b418b[_0x4e8a('0x54')],null))[_0x4e8a('0x1f')](respondWithResult(_0x5a9873,null))[_0x4e8a('0x28')](handleError(_0x5a9873,null));};exports[_0x4e8a('0x5f')]=function(_0x41a277,_0x273970){return db[_0x4e8a('0x36')][_0x4e8a('0x5a')]({'where':{'id':_0x41a277['params']['id']}})[_0x4e8a('0x1f')](handleEntityNotFound(_0x273970,null))[_0x4e8a('0x1f')](removeEntity(_0x273970,null))[_0x4e8a('0x28')](handleError(_0x273970,null));};exports[_0x4e8a('0x60')]=function(_0x19c96f,_0x24e88e){return db[_0x4e8a('0x36')]['describe']()[_0x4e8a('0x1f')](respondWithResult(_0x24e88e,null))['catch'](handleError(_0x24e88e,null));};exports['addDisposition']=function(_0x16e344,_0x5a5e82,_0x48be64){if(_0x16e344[_0x4e8a('0x54')]['id']){delete _0x16e344[_0x4e8a('0x54')]['id'];}return db[_0x4e8a('0x36')][_0x4e8a('0x5a')]({'where':{'id':_0x16e344[_0x4e8a('0x4d')]['id']}})[_0x4e8a('0x1f')](handleEntityNotFound(_0x5a5e82,null))[_0x4e8a('0x1f')](function(_0x538a01){if(_0x538a01){_0x16e344[_0x4e8a('0x54')][_0x4e8a('0x61')]=_0x538a01['id'];return db[_0x4e8a('0x62')][_0x4e8a('0x53')](_0x16e344[_0x4e8a('0x54')]);}})[_0x4e8a('0x1f')](respondWithResult(_0x5a5e82,null))[_0x4e8a('0x28')](handleError(_0x5a5e82,null));};exports[_0x4e8a('0x63')]=function(_0x373840,_0x199372,_0x269e2f){var _0x4d87ea={'raw':![],'where':{}};var _0xd64425={};var _0x5085d7={'count':0x0,'rows':[]};return db['OpenchannelAccount'][_0x4e8a('0x64')]({'where':{'id':_0x373840['params']['id']}})['then'](handleEntityNotFound(_0x199372,null))[_0x4e8a('0x1f')](function(_0x3f31bf){if(_0x3f31bf){_0xd64425[_0x4e8a('0x39')]=_['keys'](db[_0x4e8a('0x62')]['rawAttributes']);_0xd64425[_0x4e8a('0x3b')]=_[_0x4e8a('0x3c')](_0x373840[_0x4e8a('0x3b')]);_0xd64425['filters']=_[_0x4e8a('0x3d')](_0xd64425[_0x4e8a('0x39')],_0xd64425[_0x4e8a('0x3b')]);_0x4d87ea[_0x4e8a('0x3e')]=_[_0x4e8a('0x3d')](_0xd64425[_0x4e8a('0x39')],qs[_0x4e8a('0x3f')](_0x373840['query'][_0x4e8a('0x3f')]));_0x4d87ea[_0x4e8a('0x3e')]=_0x4d87ea[_0x4e8a('0x3e')][_0x4e8a('0x51')]?_0x4d87ea[_0x4e8a('0x3e')]:_0xd64425[_0x4e8a('0x39')];if(!_0x373840['query']['hasOwnProperty'](_0x4e8a('0x41'))){_0x4d87ea['limit']=qs[_0x4e8a('0x2d')](_0x373840[_0x4e8a('0x3b')][_0x4e8a('0x2d')]);_0x4d87ea[_0x4e8a('0x2b')]=qs[_0x4e8a('0x2b')](_0x373840['query'][_0x4e8a('0x2b')]);}_0x4d87ea[_0x4e8a('0x42')]=qs[_0x4e8a('0x43')](_0x373840[_0x4e8a('0x3b')][_0x4e8a('0x43')]);_0x4d87ea[_0x4e8a('0x44')]=qs['filters'](_[_0x4e8a('0x45')](_0x373840[_0x4e8a('0x3b')],_0xd64425[_0x4e8a('0x50')]));_0x4d87ea['where'][_0x4e8a('0x61')]=_0x3f31bf['id'];if(_0x373840[_0x4e8a('0x3b')][_0x4e8a('0x46')]){_0x4d87ea[_0x4e8a('0x44')]=_[_0x4e8a('0x52')](_0x4d87ea[_0x4e8a('0x44')],{'$or':_['map'](_0x4d87ea[_0x4e8a('0x3e')],function(_0x2a0337){var _0x3716f5={};_0x3716f5[_0x2a0337]={'$like':'%'+_0x373840[_0x4e8a('0x3b')][_0x4e8a('0x46')]+'%'};return _0x3716f5;})});}_0x4d87ea=_['merge']({},_0x4d87ea,_0x373840[_0x4e8a('0x48')]);return db['Disposition'][_0x4e8a('0x49')]({'where':_0x4d87ea[_0x4e8a('0x44')]})[_0x4e8a('0x1f')](function(_0xf168f8){_0x5085d7['count']=_0xf168f8;if(_0x373840[_0x4e8a('0x3b')][_0x4e8a('0x4a')]){_0x4d87ea['include']=[{'all':!![]}];}return db[_0x4e8a('0x62')][_0x4e8a('0x65')](_0x4d87ea);})['then'](function(_0x1260b8){_0x5085d7[_0x4e8a('0x66')]=_0x1260b8;return _0x5085d7;});}})['then'](respondWithFilteredResult(_0x199372,_0x4d87ea))[_0x4e8a('0x28')](handleError(_0x199372,null));};exports[_0x4e8a('0x67')]=function(_0x207042,_0x3a1902,_0xf8d79){return db[_0x4e8a('0x36')][_0x4e8a('0x5a')]({'where':{'id':_0x207042[_0x4e8a('0x4d')]['id']}})['then'](handleEntityNotFound(_0x3a1902,null))[_0x4e8a('0x1f')](function(_0x480b18){if(_0x480b18){return _0x480b18['removeDispositions'](_0x207042['query']['ids']);}})[_0x4e8a('0x1f')](respondWithStatusCode(_0x3a1902,null))[_0x4e8a('0x28')](handleError(_0x3a1902,null));};exports[_0x4e8a('0x68')]=function(_0x24d1d1,_0x425bd8,_0x48f51d){if(_0x24d1d1[_0x4e8a('0x54')]['id']){delete _0x24d1d1[_0x4e8a('0x54')]['id'];}return db[_0x4e8a('0x36')][_0x4e8a('0x5a')]({'where':{'id':_0x24d1d1['params']['id']}})[_0x4e8a('0x1f')](handleEntityNotFound(_0x425bd8,null))[_0x4e8a('0x1f')](function(_0x281723){if(_0x281723){_0x24d1d1[_0x4e8a('0x54')][_0x4e8a('0x61')]=_0x281723['id'];return db[_0x4e8a('0x69')][_0x4e8a('0x53')](_0x24d1d1['body']);}})[_0x4e8a('0x1f')](respondWithResult(_0x425bd8,null))[_0x4e8a('0x28')](handleError(_0x425bd8,null));};exports['getAnswers']=function(_0x4bc834,_0x18d2e4,_0x207177){var _0x448b0c={'raw':![],'where':{}};var _0x338644={};var _0x1fbfcb={'count':0x0,'rows':[]};return db[_0x4e8a('0x36')][_0x4e8a('0x64')]({'where':{'id':_0x4bc834[_0x4e8a('0x4d')]['id']}})[_0x4e8a('0x1f')](handleEntityNotFound(_0x18d2e4,null))[_0x4e8a('0x1f')](function(_0x59b671){if(_0x59b671){_0x338644[_0x4e8a('0x39')]=_[_0x4e8a('0x3c')](db['CannedAnswer']['rawAttributes']);_0x338644['query']=_['keys'](_0x4bc834['query']);_0x338644[_0x4e8a('0x50')]=_[_0x4e8a('0x3d')](_0x338644[_0x4e8a('0x39')],_0x338644[_0x4e8a('0x3b')]);_0x448b0c[_0x4e8a('0x3e')]=_[_0x4e8a('0x3d')](_0x338644[_0x4e8a('0x39')],qs[_0x4e8a('0x3f')](_0x4bc834[_0x4e8a('0x3b')]['fields']));_0x448b0c['attributes']=_0x448b0c[_0x4e8a('0x3e')][_0x4e8a('0x51')]?_0x448b0c[_0x4e8a('0x3e')]:_0x338644[_0x4e8a('0x39')];if(!_0x4bc834[_0x4e8a('0x3b')][_0x4e8a('0x40')](_0x4e8a('0x41'))){_0x448b0c[_0x4e8a('0x2d')]=qs[_0x4e8a('0x2d')](_0x4bc834['query'][_0x4e8a('0x2d')]);_0x448b0c[_0x4e8a('0x2b')]=qs[_0x4e8a('0x2b')](_0x4bc834[_0x4e8a('0x3b')][_0x4e8a('0x2b')]);}_0x448b0c[_0x4e8a('0x42')]=qs[_0x4e8a('0x43')](_0x4bc834[_0x4e8a('0x3b')][_0x4e8a('0x43')]);_0x448b0c[_0x4e8a('0x44')]=qs[_0x4e8a('0x50')](_[_0x4e8a('0x45')](_0x4bc834[_0x4e8a('0x3b')],_0x338644[_0x4e8a('0x50')]));_0x448b0c[_0x4e8a('0x44')][_0x4e8a('0x61')]=_0x59b671['id'];if(_0x4bc834[_0x4e8a('0x3b')][_0x4e8a('0x46')]){_0x448b0c[_0x4e8a('0x44')]=_['merge'](_0x448b0c['where'],{'$or':_[_0x4e8a('0x3a')](_0x448b0c[_0x4e8a('0x3e')],function(_0x4a8d3c){var _0x27f2aa={};_0x27f2aa[_0x4a8d3c]={'$like':'%'+_0x4bc834[_0x4e8a('0x3b')][_0x4e8a('0x46')]+'%'};return _0x27f2aa;})});}_0x448b0c=_[_0x4e8a('0x52')]({},_0x448b0c,_0x4bc834[_0x4e8a('0x48')]);return db[_0x4e8a('0x69')][_0x4e8a('0x49')]({'where':_0x448b0c['where']})['then'](function(_0x31f050){_0x1fbfcb[_0x4e8a('0x49')]=_0x31f050;if(_0x4bc834['query'][_0x4e8a('0x4a')]){_0x448b0c['include']=[{'all':!![]}];}return db['CannedAnswer'][_0x4e8a('0x65')](_0x448b0c);})['then'](function(_0x17c2e6){_0x1fbfcb['rows']=_0x17c2e6;return _0x1fbfcb;});}})[_0x4e8a('0x1f')](respondWithFilteredResult(_0x18d2e4,_0x448b0c))['catch'](handleError(_0x18d2e4,null));};exports[_0x4e8a('0x6a')]=function(_0x51ca02,_0x23b8dd,_0x30bc95){return db[_0x4e8a('0x36')][_0x4e8a('0x5a')]({'where':{'id':_0x51ca02[_0x4e8a('0x4d')]['id']}})[_0x4e8a('0x1f')](handleEntityNotFound(_0x23b8dd,null))[_0x4e8a('0x1f')](function(_0x506331){if(_0x506331){return _0x506331[_0x4e8a('0x6a')](_0x51ca02[_0x4e8a('0x3b')][_0x4e8a('0x6b')]);}})['then'](respondWithStatusCode(_0x23b8dd,null))[_0x4e8a('0x28')](handleError(_0x23b8dd,null));};exports[_0x4e8a('0x6c')]=function(_0x18248e,_0x1a245,_0x25df7c){var _0x5ea155={'body':_0x18248e['body'],'channel':_0x4e8a('0x6d')};var _0x4cc2d0=[];var _0x149581=[];var _0x5253fe={};var _0x214d44=![];return db[_0x4e8a('0x6e')][_0x4e8a('0x60')]()[_0x4e8a('0x1f')](function(_0x307dd9){if(!_0x307dd9){throw new db[(_0x4e8a('0x6f'))][(_0x4e8a('0x70'))](_0x4e8a('0x71'));}_0x4cc2d0=_[_0x4e8a('0x72')](_[_0x4e8a('0x3c')](_0x307dd9),[_0x4e8a('0x73'),_0x4e8a('0x74')]);_0x149581=_[_0x4e8a('0x72')](_[_0x4e8a('0x3c')](_0x307dd9),[_0x4e8a('0x73'),_0x4e8a('0x74'),_0x4e8a('0x75'),'ListId']);if(_0x18248e[_0x4e8a('0x54')]['id']){delete _0x18248e[_0x4e8a('0x54')]['id'];}if(_[_0x4e8a('0x76')](_0x18248e['body'][_0x4e8a('0x77')])){throw new db[(_0x4e8a('0x6f'))][(_0x4e8a('0x70'))](_0x4e8a('0x78'));}if(_[_0x4e8a('0x76')](_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x54')])||_0x18248e[_0x4e8a('0x54')]['body']===''){throw new db['Sequelize'][(_0x4e8a('0x70'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x4e8a('0x76')](_0x18248e['body'][_0x4e8a('0x79')])){throw new db[(_0x4e8a('0x6f'))][(_0x4e8a('0x70'))](_0x4e8a('0x7a')+_0x149581);}if(!_[_0x4e8a('0x7b')](_0x149581,_0x18248e['body'][_0x4e8a('0x79')])){throw new db[(_0x4e8a('0x6f'))]['ValidationError'](_0x4e8a('0x7c')+_0x149581);}_0x5253fe[_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x79')]]=_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x77')];})[_0x4e8a('0x1f')](function(){return db['OpenchannelAccount'][_0x4e8a('0x5a')]({'where':{'id':_0x18248e['params']['id']},'include':[{'model':db['CmList'],'as':_0x4e8a('0x7d'),'include':[{'model':db[_0x4e8a('0x6e')],'as':_0x4e8a('0x7e'),'where':_0x5253fe,'limit':0x1,'order':[[_0x4e8a('0x74'),_0x4e8a('0x7f')]]}]},{'model':db[_0x4e8a('0x80')],'as':_0x4e8a('0x81')}]});})[_0x4e8a('0x1f')](handleEntityNotFound(_0x1a245,null))[_0x4e8a('0x1f')](function(_0x3d6c2e){if(_0x3d6c2e&&_0x3d6c2e['List']){_0x5ea155[_0x4e8a('0x82')]=_0x3d6c2e;_0x5ea155['applications']=_0x3d6c2e[_0x4e8a('0x81')];_0x5ea155[_0x4e8a('0x83')]=_0x3d6c2e['List'];_0x5ea155[_0x4e8a('0x84')]=_[_0x4e8a('0x85')](_0x5ea155[_0x4e8a('0x84')],['priority'],[_0x4e8a('0x86')]);if(_0x5ea155[_0x4e8a('0x82')]['Applications']){delete _0x5ea155[_0x4e8a('0x82')][_0x4e8a('0x81')];}if(_0x5ea155[_0x4e8a('0x82')]['List']&&_0x5ea155[_0x4e8a('0x82')][_0x4e8a('0x7d')][_0x4e8a('0x7e')][_0x4e8a('0x51')]){return _0x5ea155[_0x4e8a('0x82')]['List'][_0x4e8a('0x7e')][0x0];}var _0x547fa2=_[_0x4e8a('0x87')](_0x18248e['body'],{'firstName':_0x18248e[_0x4e8a('0x54')]['from'],'ListId':_0x3d6c2e[_0x4e8a('0x88')]});_0x547fa2[_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x79')]]=_0x18248e[_0x4e8a('0x54')]['from'];return db['CmContact'][_0x4e8a('0x53')](_0x547fa2,{'fields':_0x4cc2d0,'raw':!![]});}})['then'](handleEntityNotFound(_0x1a245,null))[_0x4e8a('0x1f')](function(_0x3c92aa){_0x5ea155['contact']=_0x3c92aa;if(_0x3c92aa){var _0x48decf={'ContactId':_0x3c92aa['id'],'OpenchannelAccountId':_0x18248e[_0x4e8a('0x4d')]['id'],'from':(_0x3c92aa[_0x4e8a('0x89')]||'')+'\x20'+(_0x3c92aa[_0x4e8a('0x8a')]||'')};var _0x34669a={'OpenchannelAccountId':_0x18248e[_0x4e8a('0x4d')]['id'],'closed':![]};if(_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x8b')]){_0x34669a[_0x4e8a('0x8b')]=_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x8b')];return db['OpenchannelInteraction'][_0x4e8a('0x5a')]({'where':_0x34669a})[_0x4e8a('0x1f')](function(_0x1ca2d3){if(_0x1ca2d3){return[_0x1ca2d3,![]];}_0x48decf[_0x4e8a('0x8b')]=_0x18248e['body'][_0x4e8a('0x8b')];_0x48decf[_0x4e8a('0x8c')]=_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x8c')];return db['OpenchannelInteraction'][_0x4e8a('0x53')](_0x48decf)[_0x4e8a('0x1f')](function(_0x642cf2){return[_0x642cf2,!![]];});});}else{_0x34669a[_0x4e8a('0x8b')]=null;}_0x34669a['ContactId']=_0x3c92aa['id'];return db[_0x4e8a('0x8d')]['find']({'where':_0x34669a})[_0x4e8a('0x1f')](function(_0x2f6414){if(_0x2f6414){return[_0x2f6414,![]];}return db[_0x4e8a('0x8d')][_0x4e8a('0x53')](_0x48decf)['then'](function(_0x4bd604){return[_0x4bd604,!![]];});});}})[_0x4e8a('0x8e')](function(_0xe6f7df,_0x57e652){if(_0xe6f7df){_0x214d44=_0x57e652;if(!_0x57e652){var _0x5938b1={'from':(_0x5ea155[_0x4e8a('0x8f')][_0x4e8a('0x89')]||'')+'\x20'+(_0x5ea155[_0x4e8a('0x8f')][_0x4e8a('0x8a')]||'')};if(_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x8b')]&&_0x18248e['body']['messageId']&&_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x8b')]!=_0x18248e[_0x4e8a('0x54')]['messageId']){_0x5938b1[_0x4e8a('0x8b')]=_0x18248e['body'][_0x4e8a('0x90')];}return _0xe6f7df[_0x4e8a('0x31')](_0x5938b1);}else{return _0xe6f7df;}}})[_0x4e8a('0x1f')](function(_0x2df779){_0x5ea155[_0x4e8a('0x91')]=_0x2df779[_0x4e8a('0x32')]({'plain':!![]});_0x5ea155[_0x4e8a('0x91')][_0x4e8a('0x92')]=_0x214d44;if(_0x5ea155['interaction'][_0x4e8a('0x92')]){if(_0x5ea155[_0x4e8a('0x82')][_0x4e8a('0x93')]){_0x5ea155[_0x4e8a('0x84')][_0x4e8a('0x94')]({'id':0x0,'priority':_0x5ea155[_0x4e8a('0x84')][_0x4e8a('0x51')]+0x1,'app':_0x4e8a('0x95'),'appdata':_0x4e8a('0x96'),'interval':_0x4e8a('0x97')});}}return db[_0x4e8a('0x98')]['create']({'body':_0x18248e['body'][_0x4e8a('0x54')],'OpenchannelAccountId':_0x18248e[_0x4e8a('0x4d')]['id'],'OpenchannelInteractionId':_0x2df779['id'],'direction':'in','ContactId':_0x5ea155[_0x4e8a('0x8f')]['id'],'AttachmentId':_0x18248e[_0x4e8a('0x54')][_0x4e8a('0x99')]});})['then'](function(_0x224681){_0x5ea155[_0x4e8a('0x27')]=_0x224681;if(_0x5ea155[_0x4e8a('0x91')][_0x4e8a('0x9a')]){return db['User']['find']({'attributes':['id',_0x4e8a('0x5d')],'where':{'id':_0x5ea155['interaction'][_0x4e8a('0x9a')]}})[_0x4e8a('0x1f')](function(_0x6a3ca1){if(_0x6a3ca1){_0x5ea155[_0x4e8a('0x84')][_0x4e8a('0x9b')]({'id':0x0,'priority':0x0,'app':_0x4e8a('0x9c'),'appdata':_0x6a3ca1['name']+','+(_0x5ea155[_0x4e8a('0x82')][_0x4e8a('0x9d')]||0xa),'interval':_0x4e8a('0x97')});_0x5ea155[_0x4e8a('0x9e')]=![];}return respondWithRpcPromise(_0x4e8a('0x9f'),_0x4e8a('0xa0'),_0x5ea155);});}return respondWithRpcPromise('Start',_0x4e8a('0xa0'),_0x5ea155);})[_0x4e8a('0x1f')](function(_0x21193d){respondWithRpcPromise(_0x4e8a('0xa1'),'EventManager',{'event':_0x4e8a('0x6c'),'message':_0x21193d},client9002);return _0x21193d;})[_0x4e8a('0x1f')](respondWithResult(_0x1a245,null))['catch'](handleError(_0x1a245,null));};exports[_0x4e8a('0xa2')]=function(_0xc17b81,_0x700386){var _0x7accea=_0xc17b81[_0x4e8a('0x4d')]['id'];var _0x3adf9=_0xc17b81[_0x4e8a('0x54')];var _0x2e4993=0xc8;var _0xb91f6a=null;return db[_0x4e8a('0xa3')][_0x4e8a('0xa4')]({'isolationLevel':db[_0x4e8a('0xa3')][_0x4e8a('0xa5')][_0x4e8a('0xa6')][_0x4e8a('0xa7')]},function(_0x34d6d7){return db[_0x4e8a('0x36')][_0x4e8a('0x64')]({'where':{'id':_0x7accea},'transaction':_0x34d6d7})['then'](function(_0x45b678){if(_0x45b678){return db['OpenchannelApplication']['destroy']({'where':{'OpenchannelAccountId':_0x7accea},'transaction':_0x34d6d7})[_0x4e8a('0x1f')](function(){var _0x3f2bbc=_[_0x4e8a('0x3a')](_0x3adf9,function(_0x5315b6){_0x5315b6[_0x4e8a('0x61')]=_0x7accea;return _0x5315b6;});return db[_0x4e8a('0x80')][_0x4e8a('0xa8')](_0x3f2bbc,{'transaction':_0x34d6d7});});}else{_0x2e4993=0x194;_0xb91f6a=[];}});})[_0x4e8a('0x1f')](function(){if(_0x2e4993!==0x194){return db[_0x4e8a('0x80')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0x7accea},'order':'priority'})['then'](function(_0x1c4382){_0xb91f6a=_0x1c4382;});}})[_0x4e8a('0x28')](function(_0x1dc1a6){_0x2e4993=0x1f4;logger[_0x4e8a('0x26')](_0x1dc1a6['stack']);if(_0x1dc1a6[_0x4e8a('0x5d')]){delete _0x1dc1a6[_0x4e8a('0x5d')];}_0xb91f6a=_0x1dc1a6;})[_0x4e8a('0xa9')](function(){if(_0xb91f6a===null){_0x700386['sendStatus'](_0x2e4993);}else{if(_0x2e4993===0x1f4){_0x700386[_0x4e8a('0x2a')](_0x2e4993)[_0x4e8a('0x34')](_0xb91f6a);}else{_0x700386[_0x4e8a('0x2a')](_0x2e4993)[_0x4e8a('0xaa')](_0xb91f6a);}}});};exports[_0x4e8a('0xab')]=function(_0x1dbf0a,_0x3c1d5f,_0x19ddcc){var _0x4bafed={};var _0x288bb3={};var _0x2c45c0;var _0x465aa7;return db['OpenchannelAccount'][_0x4e8a('0x64')]({'where':{'id':_0x1dbf0a['params']['id']}})[_0x4e8a('0x1f')](handleEntityNotFound(_0x3c1d5f,null))['then'](function(_0x119115){if(_0x119115){_0x2c45c0=_0x119115;_0x288bb3[_0x4e8a('0x39')]=_[_0x4e8a('0x3c')](db[_0x4e8a('0x80')][_0x4e8a('0x4f')]);_0x288bb3[_0x4e8a('0x3b')]=_[_0x4e8a('0x3c')](_0x1dbf0a['query']);_0x288bb3[_0x4e8a('0x50')]=_['intersection'](_0x288bb3[_0x4e8a('0x39')],_0x288bb3[_0x4e8a('0x3b')]);_0x4bafed[_0x4e8a('0x3e')]=_['intersection'](_0x288bb3[_0x4e8a('0x39')],qs[_0x4e8a('0x3f')](_0x1dbf0a[_0x4e8a('0x3b')][_0x4e8a('0x3f')]));_0x4bafed['attributes']=_0x4bafed[_0x4e8a('0x3e')][_0x4e8a('0x51')]?_0x4bafed[_0x4e8a('0x3e')]:_0x288bb3[_0x4e8a('0x39')];_0x4bafed[_0x4e8a('0x42')]=qs[_0x4e8a('0x43')](_0x1dbf0a[_0x4e8a('0x3b')]['sort']);_0x4bafed['where']=qs[_0x4e8a('0x50')](_['pick'](_0x1dbf0a['query'],_0x288bb3[_0x4e8a('0x50')]));if(_0x1dbf0a[_0x4e8a('0x3b')][_0x4e8a('0x46')]){_0x4bafed[_0x4e8a('0x44')]=_['merge'](_0x4bafed[_0x4e8a('0x44')],{'$or':_['map'](_0x4bafed['attributes'],function(_0x2c7202){var _0x55e895={};_0x55e895[_0x2c7202]={'$like':'%'+_0x1dbf0a[_0x4e8a('0x3b')][_0x4e8a('0x46')]+'%'};return _0x55e895;})});}_0x4bafed=_['merge']({},_0x4bafed,_0x1dbf0a[_0x4e8a('0x48')]);return _0x2c45c0[_0x4e8a('0xab')](_0x4bafed);}})[_0x4e8a('0x1f')](function(_0x51578a){if(_0x51578a){_0x465aa7=_0x51578a[_0x4e8a('0x51')];if(!_0x1dbf0a[_0x4e8a('0x3b')][_0x4e8a('0x40')](_0x4e8a('0x41'))){_0x4bafed[_0x4e8a('0x2d')]=qs[_0x4e8a('0x2d')](_0x1dbf0a[_0x4e8a('0x3b')][_0x4e8a('0x2d')]);_0x4bafed[_0x4e8a('0x2b')]=qs[_0x4e8a('0x2b')](_0x1dbf0a['query']['offset']);}return _0x2c45c0[_0x4e8a('0xab')](_0x4bafed);}})['then'](function(_0x3c936b){if(_0x3c936b){return _0x3c936b?{'count':_0x465aa7,'rows':_0x3c936b}:null;}})[_0x4e8a('0x1f')](respondWithResult(_0x3c1d5f,null))[_0x4e8a('0x28')](handleError(_0x3c1d5f,null));};exports['getInteractions']=function(_0x119aca,_0x1309fd,_0x5290b1){var _0x200939={'raw':![],'where':{}};var _0x53fa64={};var _0x2787be={'count':0x0,'rows':[]};return db[_0x4e8a('0x36')][_0x4e8a('0x64')]({'where':{'id':_0x119aca[_0x4e8a('0x4d')]['id']}})[_0x4e8a('0x1f')](handleEntityNotFound(_0x1309fd,null))[_0x4e8a('0x1f')](function(_0x218a9b){if(_0x218a9b){_0x53fa64[_0x4e8a('0x39')]=_['keys'](db[_0x4e8a('0x8d')][_0x4e8a('0x4f')]);_0x53fa64[_0x4e8a('0x3b')]=_[_0x4e8a('0x3c')](_0x119aca[_0x4e8a('0x3b')]);_0x53fa64[_0x4e8a('0x50')]=_[_0x4e8a('0x3d')](_0x53fa64['model'],_0x53fa64[_0x4e8a('0x3b')]);_0x200939[_0x4e8a('0x3e')]=_[_0x4e8a('0x3d')](_0x53fa64[_0x4e8a('0x39')],qs['fields'](_0x119aca[_0x4e8a('0x3b')]['fields']));_0x200939[_0x4e8a('0x3e')]=_0x200939[_0x4e8a('0x3e')][_0x4e8a('0x51')]?_0x200939[_0x4e8a('0x3e')]:_0x53fa64[_0x4e8a('0x39')];if(!_0x119aca[_0x4e8a('0x3b')]['hasOwnProperty'](_0x4e8a('0x41'))){_0x200939['limit']=qs[_0x4e8a('0x2d')](_0x119aca['query'][_0x4e8a('0x2d')]);_0x200939[_0x4e8a('0x2b')]=qs['offset'](_0x119aca['query'][_0x4e8a('0x2b')]);}_0x200939[_0x4e8a('0x42')]=qs[_0x4e8a('0x43')](_0x119aca['query']['sort']);_0x200939[_0x4e8a('0x44')]=qs[_0x4e8a('0x50')](_[_0x4e8a('0x45')](_0x119aca['query'],_0x53fa64[_0x4e8a('0x50')]));_0x200939[_0x4e8a('0x44')][_0x4e8a('0x61')]=_0x218a9b['id'];if(_0x119aca[_0x4e8a('0x3b')][_0x4e8a('0x46')]){_0x200939['where']=_[_0x4e8a('0x52')](_0x200939[_0x4e8a('0x44')],{'$or':_[_0x4e8a('0x3a')](_0x200939[_0x4e8a('0x3e')],function(_0x413213){var _0x4476c7={};_0x4476c7[_0x413213]={'$like':'%'+_0x119aca[_0x4e8a('0x3b')][_0x4e8a('0x46')]+'%'};return _0x4476c7;})});}_0x200939=_['merge']({},_0x200939,_0x119aca[_0x4e8a('0x48')]);return db['OpenchannelInteraction'][_0x4e8a('0x49')]({'where':_0x200939['where']})[_0x4e8a('0x1f')](function(_0x1ce93d){_0x2787be['count']=_0x1ce93d;if(_0x119aca[_0x4e8a('0x3b')][_0x4e8a('0x4a')]){_0x200939[_0x4e8a('0x4b')]=[{'model':db['CmContact'],'as':_0x4e8a('0xac'),'required':![]},{'model':db[_0x4e8a('0xad')],'as':_0x4e8a('0xae'),'attributes':[_0x4e8a('0x5d'),_0x4e8a('0xaf'),'internal'],'required':![]},{'model':db[_0x4e8a('0xb0')],'as':_0x4e8a('0xb1'),'attributes':['id',_0x4e8a('0x5d'),_0x4e8a('0xb2')],'where':_0x119aca[_0x4e8a('0x3b')][_0x4e8a('0xb3')]?{'id':_0x119aca[_0x4e8a('0x3b')][_0x4e8a('0xb3')]}:undefined,'required':_0x119aca[_0x4e8a('0x3b')][_0x4e8a('0xb3')]?!![]:![]}];}return db[_0x4e8a('0x8d')]['findAll'](_0x200939);})[_0x4e8a('0x1f')](function(_0x53181a){_0x2787be[_0x4e8a('0x66')]=_0x53181a;return _0x2787be;});}})[_0x4e8a('0x1f')](respondWithFilteredResult(_0x1309fd,_0x200939))[_0x4e8a('0x28')](handleError(_0x1309fd,null));};exports[_0x4e8a('0xb4')]=function(_0x12c01c,_0x20d19b,_0x46fe87){return db[_0x4e8a('0x36')][_0x4e8a('0x5a')]({'where':{'id':_0x12c01c['params']['id']}})['then'](handleEntityNotFound(_0x20d19b,null))['then'](function(_0x311abf){if(_0x311abf){return _0x311abf[_0x4e8a('0xb4')](_0x12c01c[_0x4e8a('0x54')][_0x4e8a('0x6b')],_[_0x4e8a('0xb5')](_0x12c01c[_0x4e8a('0x54')],['ids','id'])||{})['spread'](function(_0x147937){for(var _0x5250c5=0x0;_0x5250c5<_0x12c01c[_0x4e8a('0x54')]['ids'][_0x4e8a('0x51')];_0x5250c5+=0x1){socket[_0x4e8a('0xb6')](_0x4e8a('0xb7'),{'UserId':Number(_0x12c01c[_0x4e8a('0x54')][_0x4e8a('0x6b')][_0x5250c5]),'OpenchannelAccountId':Number(_0x12c01c[_0x4e8a('0x4d')]['id'])});}return _0x147937;});}})['then'](respondWithResult(_0x20d19b,null))[_0x4e8a('0x28')](handleError(_0x20d19b,null));};exports[_0x4e8a('0xb8')]=function(_0xda3a48,_0x59b94d,_0xa01a57){return db[_0x4e8a('0x36')][_0x4e8a('0x5a')]({'where':{'id':_0xda3a48[_0x4e8a('0x4d')]['id']}})[_0x4e8a('0x1f')](handleEntityNotFound(_0x59b94d,null))[_0x4e8a('0x1f')](function(_0x4b6cd7){if(_0x4b6cd7){return _0x4b6cd7[_0x4e8a('0xb8')](_0xda3a48[_0x4e8a('0x3b')]['ids'])[_0x4e8a('0x1f')](function(){if(_['isArray'](_0xda3a48['query']['ids'])){for(var _0x54d9f5=0x0;_0x54d9f5<_0xda3a48['query'][_0x4e8a('0x6b')][_0x4e8a('0x51')];_0x54d9f5+=0x1){socket[_0x4e8a('0xb6')]('userOpenchannelAccount:remove',{'UserId':Number(_0xda3a48[_0x4e8a('0x3b')][_0x4e8a('0x6b')][_0x54d9f5]),'OpenchannelAccountId':Number(_0xda3a48[_0x4e8a('0x4d')]['id'])});}}else{socket[_0x4e8a('0xb6')](_0x4e8a('0xb9'),{'UserId':Number(_0xda3a48[_0x4e8a('0x3b')]['ids']),'OpenchannelAccountId':Number(_0xda3a48['params']['id'])});}});}})[_0x4e8a('0x1f')](respondWithStatusCode(_0x59b94d,null))[_0x4e8a('0x28')](handleError(_0x59b94d,null));};exports[_0x4e8a('0xba')]=function(_0x1b96fd,_0x3755af,_0x42608d){var _0xfd81d9={};var _0x331fba={};var _0x13901f;var _0x4acb77;return db[_0x4e8a('0x36')][_0x4e8a('0x64')]({'where':{'id':_0x1b96fd[_0x4e8a('0x4d')]['id']}})['then'](handleEntityNotFound(_0x3755af,null))[_0x4e8a('0x1f')](function(_0x165a19){if(_0x165a19){_0x13901f=_0x165a19;_0x331fba[_0x4e8a('0x39')]=_[_0x4e8a('0x3c')](db['User'][_0x4e8a('0x4f')]);_0x331fba[_0x4e8a('0x3b')]=_[_0x4e8a('0x3c')](_0x1b96fd[_0x4e8a('0x3b')]);_0x331fba[_0x4e8a('0x50')]=_[_0x4e8a('0x3d')](_0x331fba[_0x4e8a('0x39')],_0x331fba[_0x4e8a('0x3b')]);_0xfd81d9[_0x4e8a('0x3e')]=_[_0x4e8a('0x3d')](_0x331fba[_0x4e8a('0x39')],qs[_0x4e8a('0x3f')](_0x1b96fd[_0x4e8a('0x3b')][_0x4e8a('0x3f')]));_0xfd81d9[_0x4e8a('0x3e')]=_0xfd81d9[_0x4e8a('0x3e')][_0x4e8a('0x51')]?_0xfd81d9[_0x4e8a('0x3e')]:_0x331fba['model'];_0xfd81d9[_0x4e8a('0x42')]=qs[_0x4e8a('0x43')](_0x1b96fd[_0x4e8a('0x3b')]['sort']);_0xfd81d9[_0x4e8a('0x44')]=qs['filters'](_[_0x4e8a('0x45')](_0x1b96fd[_0x4e8a('0x3b')],_0x331fba[_0x4e8a('0x50')]));if(_0x1b96fd[_0x4e8a('0x3b')][_0x4e8a('0x46')]){_0xfd81d9[_0x4e8a('0x44')]=_['merge'](_0xfd81d9[_0x4e8a('0x44')],{'$or':_[_0x4e8a('0x3a')](_0xfd81d9[_0x4e8a('0x3e')],function(_0x4073a){var _0xe954d={};_0xe954d[_0x4073a]={'$like':'%'+_0x1b96fd[_0x4e8a('0x3b')][_0x4e8a('0x46')]+'%'};return _0xe954d;})});}_0xfd81d9=_[_0x4e8a('0x52')]({},_0xfd81d9,_0x1b96fd[_0x4e8a('0x48')]);return _0x13901f[_0x4e8a('0xba')](_0xfd81d9);}})[_0x4e8a('0x1f')](function(_0x279e9b){if(_0x279e9b){_0x4acb77=_0x279e9b['length'];if(!_0x1b96fd[_0x4e8a('0x3b')]['hasOwnProperty'](_0x4e8a('0x41'))){_0xfd81d9['limit']=qs[_0x4e8a('0x2d')](_0x1b96fd[_0x4e8a('0x3b')]['limit']);_0xfd81d9[_0x4e8a('0x2b')]=qs[_0x4e8a('0x2b')](_0x1b96fd[_0x4e8a('0x3b')][_0x4e8a('0x2b')]);}return _0x13901f[_0x4e8a('0xba')](_0xfd81d9);}})[_0x4e8a('0x1f')](function(_0x22bb64){if(_0x22bb64){return _0x22bb64?{'count':_0x4acb77,'rows':_0x22bb64}:null;}})[_0x4e8a('0x1f')](respondWithResult(_0x3755af,null))['catch'](handleError(_0x3755af,null));};exports[_0x4e8a('0x34')]=function(_0xb8b053,_0x262584,_0x2b5819){var _0x4b5a26,_0x241071,_0x1af060;if(_['isNil'](_0xb8b053[_0x4e8a('0x54')][_0x4e8a('0x54')])||_0xb8b053['body'][_0x4e8a('0x54')]===''){throw new db[(_0x4e8a('0x6f'))][(_0x4e8a('0x70'))](_0x4e8a('0xbb'));}if(_['isNil'](_0xb8b053['body']['to'])){}_0x4b5a26=_0xb8b053[_0x4e8a('0x54')]['to'];return db['OpenchannelAccount'][_0x4e8a('0x64')]({'where':{'id':_0xb8b053[_0x4e8a('0x4d')]['id']}})['then'](handleEntityNotFound(_0x262584,null))['then'](function(_0x549920){if(_0x549920){return db[_0x4e8a('0x36')][_0x4e8a('0x5a')]({'where':{'id':_0x549920['id']},'include':[{'model':db[_0x4e8a('0xbc')],'as':_0x4e8a('0x7d'),'include':[{'model':db['CmContact'],'as':_0x4e8a('0x7e'),'where':{[_0x549920['mapKey']]:_0x4b5a26},'limit':0x1,'order':[[_0x4e8a('0x74'),_0x4e8a('0x7f')]]}]}]})[_0x4e8a('0x1f')](handleEntityNotFound(_0x262584,null))['then'](function(_0x1ee4b1){if(_0x1ee4b1&&_0x1ee4b1[_0x4e8a('0x7d')]){_0x241071=_0x1ee4b1[_0x4e8a('0x32')]({'plain':!![]});if(_0x241071['List']&&_0x241071['List'][_0x4e8a('0x7e')][_0x4e8a('0x51')]){return _0x241071['List'][_0x4e8a('0x7e')][0x0];}return db[_0x4e8a('0x6e')][_0x4e8a('0x53')](_[_0x4e8a('0x87')](_0xb8b053['body'],{'firstName':_0x4b5a26,[_0x1ee4b1[_0x4e8a('0x79')]]:_0x4b5a26,'phone':_0x4b5a26,'ListId':_0x241071[_0x4e8a('0x88')]}));}})['then'](handleEntityNotFound(_0x262584,null))[_0x4e8a('0x1f')](function(_0x35457b){if(_0x35457b){_0x1af060=_0x35457b;return db['OpenchannelInteraction']['find']({'where':{'ContactId':_0x1af060['id'],'closed':![],'OpenchannelAccountId':_0x241071['id']}})['then'](function(_0x3fbaec){if(_0x3fbaec){return[_0x3fbaec,![]];}return db[_0x4e8a('0x8d')][_0x4e8a('0x53')]({'UserId':_0xb8b053[_0x4e8a('0x55')]['id'],'ContactId':_0x1af060['id'],'OpenchannelAccountId':_0x241071['id'],'lastMsgDirection':_0x4e8a('0xbd'),'firstMsgDirection':_0x4e8a('0xbd'),'Messages':[_['merge'](_0xb8b053['body'],{'read':![],'body':_0xb8b053[_0x4e8a('0x54')][_0x4e8a('0x54')],'OpenchannelAccountId':_0x241071['id'],'UserId':_0xb8b053['user']['id'],'ContactId':_0x1af060['id']})]},{'include':[{'model':db[_0x4e8a('0x98')],'as':'Messages'}]})[_0x4e8a('0x1f')](function(_0x56631e){return[_0x56631e,!![]];});});}})['spread'](function(_0x36fef7,_0x446c57){if(_0x446c57){return _0x36fef7;}return db[_0x4e8a('0x98')][_0x4e8a('0x53')](_['merge'](_0xb8b053[_0x4e8a('0x54')],{'read':![],'body':_0xb8b053[_0x4e8a('0x54')][_0x4e8a('0x54')],'OpenchannelAccountId':_0x241071['id'],'OpenchannelInteractionId':_0x36fef7['id'],'UserId':_0xb8b053[_0x4e8a('0x55')]['id'],'ContactId':_0x1af060['id']}))[_0x4e8a('0x1f')](function(_0x4f0f86){_0x36fef7[_0x4e8a('0xbe')]['Messages']=[];_0x36fef7[_0x4e8a('0xbe')][_0x4e8a('0xbf')][_0x4e8a('0x94')](_0x4f0f86[_0x4e8a('0xbe')]);return _0x36fef7;});});}})[_0x4e8a('0x1f')](respondWithResult(_0x262584,null))['catch'](handleError(_0x262584,null));};
\ No newline at end of file