Built motion from commit (unavailable).|2.5.18
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index 2ce26b6..0fb2848 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf2da=['user','find','userProfileId','describe','addDisposition','OpnechannelAccountId','getDispositions','hasOwnProperty','order','Disposition','removeDispositions','ids','CannedAnswer','findOne','OpenchannelAccountId','removeAnswers','notify','CmContact','no\x20available\x20attributes','createdAt','updatedAt','ListId','isNil','from','from\x20is\x20mandatory','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','CmList','List','Contacts','DESC','OpenchannelApplication','Applications','account','applications','list','orderBy','priority','asc','contact','firstName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','messageId','interaction','created','autoclose','push','close','unmanaged','*,*,*,*','OpenchannelMessage','User','agent','Start','startRouting','EventManager','addApplications','bulkCreate','findAndCountAll','getApplications','getInteractions','Contact','Owner','fullname','internal','Tag','Tags','color','tag','findAll','addAgents','omit','emit','userOpenchannelAccount:save','removeAgents','userOpenchannelAccount:remove','getAgents','out','Messages','dataValues','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','sox','ejs','lodash','squel','crypto','desk.js','to-csv','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','defaults','jayson/promise','client','http','test','Sequelize','ValidationError','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','count','offset','limit','set','Content-Range','json','reject','save','update','destroy','OpenchannelAccounts','UserProfileResource','name','send','index','Pause','mandatoryDispositionPause','OpenchannelAccount','rawAttributes','fieldName','key','model','map','query','keys','intersection','fields','attributes','length','nolimit','sort','filters','pick','filter','where','merge','type','VIRTUAL','includeAll','include','rows','params','options','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role'];(function(_0x4405ee,_0x4c485a){var _0x28f4ce=function(_0x325c13){while(--_0x325c13){_0x4405ee['push'](_0x4405ee['shift']());}};_0x28f4ce(++_0x4c485a);}(_0xf2da,0x107));var _0xaf2d=function(_0xe45118,_0x5dffbc){_0xe45118=_0xe45118-0x0;var _0x15e15d=_0xf2da[_0xe45118];return _0x15e15d;};'use strict';var pdf=require(_0xaf2d('0x0'));var emlformat=require(_0xaf2d('0x1'));var rimraf=require(_0xaf2d('0x2'));var zipdir=require(_0xaf2d('0x3'));var jsonpatch=require(_0xaf2d('0x4'));var rp=require('request-promise');var moment=require(_0xaf2d('0x5'));var BPromise=require(_0xaf2d('0x6'));var Mustache=require('mustache');var util=require(_0xaf2d('0x7'));var path=require(_0xaf2d('0x8'));var sox=require(_0xaf2d('0x9'));var csv=require('to-csv');var ejs=require(_0xaf2d('0xa'));var fs=require('fs');var _=require(_0xaf2d('0xb'));var squel=require(_0xaf2d('0xc'));var crypto=require(_0xaf2d('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xaf2d('0xe'));var toCsv=require(_0xaf2d('0xf'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xaf2d('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xaf2d('0x11'));var hardwareService=require(_0xaf2d('0x12'));var logger=require(_0xaf2d('0x13'))('api');var utils=require(_0xaf2d('0x14'));var config=require('../../config/environment');var db=require(_0xaf2d('0x15'))['db'];config['redis']=_[_0xaf2d('0x16')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./openchannelAccount.socket')['register'](socket);var jayson=require(_0xaf2d('0x17'));var client=jayson[_0xaf2d('0x18')][_0xaf2d('0x19')]({'port':0x232c});var client9002=jayson[_0xaf2d('0x18')][_0xaf2d('0x19')]({'port':0x232a});function checkPasswordPattern(_0x48bdff,_0x162ebb,_0x12c180){if(_0x12c180){var _0x4f16a7=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4f16a7[_0xaf2d('0x1a')](_0x162ebb)){return _0x48bdff;}else{throw new db[(_0xaf2d('0x1b'))][(_0xaf2d('0x1c'))](_0xaf2d('0x1d'));}}else{return _0x48bdff;}}function respondWithRpcPromise(_0x2cc88e,_0x4a5a7e,_0x2a282b,_0x818bce){return new BPromise(function(_0x55ad15,_0x53b438){var _0x14a456=_0x818bce||client;return _0x14a456['request'](_0x2cc88e,_0x2a282b)[_0xaf2d('0x1e')](function(_0x15e614){logger[_0xaf2d('0x1f')](_0xaf2d('0x20'),_0x4a5a7e,_0xaf2d('0x21'));logger[_0xaf2d('0x22')](_0xaf2d('0x23'),_0x4a5a7e,_0xaf2d('0x21'),JSON[_0xaf2d('0x24')](_0x15e614));if(_0x15e614[_0xaf2d('0x25')]){if(_0x15e614[_0xaf2d('0x25')][_0xaf2d('0x26')]===0x1f4){logger[_0xaf2d('0x25')](_0xaf2d('0x20'),_0x4a5a7e,_0x15e614[_0xaf2d('0x25')]['message']);return _0x53b438(_0x15e614['error']['message']);}logger[_0xaf2d('0x25')](_0xaf2d('0x20'),_0x4a5a7e,_0x15e614[_0xaf2d('0x25')][_0xaf2d('0x27')]);return _0x55ad15(_0x15e614[_0xaf2d('0x25')][_0xaf2d('0x27')]);}else{logger[_0xaf2d('0x1f')](_0xaf2d('0x20'),_0x4a5a7e,_0xaf2d('0x21'));_0x55ad15(_0x15e614[_0xaf2d('0x28')][_0xaf2d('0x27')]);}})[_0xaf2d('0x29')](function(_0x3c99e9){logger[_0xaf2d('0x25')](_0xaf2d('0x20'),_0x4a5a7e,_0x3c99e9);_0x53b438(_0x3c99e9);});});}function respondWithStatusCode(_0x459f3e,_0x42c033){_0x42c033=_0x42c033||0xcc;return function(_0x12bbfa){if(_0x12bbfa){return _0x459f3e[_0xaf2d('0x2a')](_0x42c033);}return _0x459f3e[_0xaf2d('0x2b')](_0x42c033)[_0xaf2d('0x2c')]();};}function respondWithResult(_0x3eb45d,_0x590a0b){_0x590a0b=_0x590a0b||0xc8;return function(_0x2e35d0){if(_0x2e35d0){return _0x3eb45d['status'](_0x590a0b)['json'](_0x2e35d0);}};}function respondWithFilteredResult(_0x41bc6f,_0x8f0319){return function(_0x3ecb91){if(_0x3ecb91){var _0x13f6e4=_0x3ecb91[_0xaf2d('0x2d')],_0x11618d=_0x8f0319[_0xaf2d('0x2e')],_0x2f9f7a=_0x8f0319[_0xaf2d('0x2e')]+_0x8f0319[_0xaf2d('0x2f')],_0x2d9fec;if(_0x2f9f7a>=_0x13f6e4){_0x2f9f7a=_0x13f6e4;_0x2d9fec=0xc8;}else{_0x2d9fec=0xce;}_0x41bc6f[_0xaf2d('0x2b')](_0x2d9fec);return _0x41bc6f[_0xaf2d('0x30')](_0xaf2d('0x31'),_0x11618d+'-'+_0x2f9f7a+'/'+_0x13f6e4)[_0xaf2d('0x32')](_0x3ecb91);}return null;};}function patchUpdates(_0x4b77db){return function(_0x38b75a){try{jsonpatch['apply'](_0x38b75a,_0x4b77db,!![]);}catch(_0x1fc3b7){return BPromise[_0xaf2d('0x33')](_0x1fc3b7);}return _0x38b75a[_0xaf2d('0x34')]();};}function saveUpdates(_0x4707df,_0xc62b58){return function(_0x1ef2ed){if(_0x1ef2ed){return _0x1ef2ed[_0xaf2d('0x35')](_0x4707df)[_0xaf2d('0x1e')](function(_0x15faed){return _0x15faed;});}return null;};}function removeEntity(_0xef9beb,_0x790a2e){return function(_0x41060c){if(_0x41060c){return _0x41060c[_0xaf2d('0x36')]()[_0xaf2d('0x1e')](function(){var _0x31e3c9=_0x41060c['get']({'plain':!![]});var _0x34d491=_0xaf2d('0x37');return db[_0xaf2d('0x38')]['destroy']({'where':{'type':_0x34d491,'resourceId':_0x31e3c9['id']}})[_0xaf2d('0x1e')](function(){return _0x41060c;});})[_0xaf2d('0x1e')](function(){_0xef9beb['status'](0xcc)[_0xaf2d('0x2c')]();});}};}function handleEntityNotFound(_0x35df0a,_0x428195){return function(_0x41ae49){if(!_0x41ae49){_0x35df0a[_0xaf2d('0x2a')](0x194);}return _0x41ae49;};}function handleError(_0x160ff2,_0x5ae5cb){_0x5ae5cb=_0x5ae5cb||0x1f4;return function(_0x58de55){logger[_0xaf2d('0x25')](_0x58de55['stack']);if(_0x58de55[_0xaf2d('0x39')]){delete _0x58de55['name'];}_0x160ff2[_0xaf2d('0x2b')](_0x5ae5cb)[_0xaf2d('0x3a')](_0x58de55);};}exports[_0xaf2d('0x3b')]=function(_0x4cae64,_0x38d00c){var _0xb4e6c9={'include':[{'model':db[_0xaf2d('0x3c')],'as':_0xaf2d('0x3d')}]},_0x3a23fb={},_0x3a8f40={'count':0x0,'rows':[]};var _0x421724=_['map'](db[_0xaf2d('0x3e')][_0xaf2d('0x3f')],function(_0x317008){return{'name':_0x317008[_0xaf2d('0x40')],'type':_0x317008['type'][_0xaf2d('0x41')]};});_0x3a23fb[_0xaf2d('0x42')]=_[_0xaf2d('0x43')](_0x421724,'name');_0x3a23fb[_0xaf2d('0x44')]=_[_0xaf2d('0x45')](_0x4cae64[_0xaf2d('0x44')]);_0x3a23fb['filters']=_[_0xaf2d('0x46')](_0x3a23fb[_0xaf2d('0x42')],_0x3a23fb[_0xaf2d('0x44')]);_0xb4e6c9['attributes']=_['intersection'](_0x3a23fb['model'],qs['fields'](_0x4cae64[_0xaf2d('0x44')][_0xaf2d('0x47')]));_0xb4e6c9[_0xaf2d('0x48')]=_0xb4e6c9[_0xaf2d('0x48')][_0xaf2d('0x49')]?_0xb4e6c9[_0xaf2d('0x48')]:_0x3a23fb[_0xaf2d('0x42')];if(!_0x4cae64['query']['hasOwnProperty'](_0xaf2d('0x4a'))){_0xb4e6c9[_0xaf2d('0x2f')]=qs[_0xaf2d('0x2f')](_0x4cae64[_0xaf2d('0x44')][_0xaf2d('0x2f')]);_0xb4e6c9[_0xaf2d('0x2e')]=qs[_0xaf2d('0x2e')](_0x4cae64[_0xaf2d('0x44')]['offset']);}_0xb4e6c9['order']=qs[_0xaf2d('0x4b')](_0x4cae64['query'][_0xaf2d('0x4b')]);_0xb4e6c9['where']=qs[_0xaf2d('0x4c')](_[_0xaf2d('0x4d')](_0x4cae64[_0xaf2d('0x44')],_0x3a23fb[_0xaf2d('0x4c')]),_0x421724);if(_0x4cae64[_0xaf2d('0x44')][_0xaf2d('0x4e')]){_0xb4e6c9[_0xaf2d('0x4f')]=_[_0xaf2d('0x50')](_0xb4e6c9[_0xaf2d('0x4f')],{'$or':_[_0xaf2d('0x43')](_0x421724,function(_0xa3b6b5){if(_0xa3b6b5[_0xaf2d('0x51')]!==_0xaf2d('0x52')){var _0x3e14bf={};_0x3e14bf[_0xa3b6b5[_0xaf2d('0x39')]]={'$like':'%'+_0x4cae64[_0xaf2d('0x44')][_0xaf2d('0x4e')]+'%'};return _0x3e14bf;}})});}_0xb4e6c9=_[_0xaf2d('0x50')]({},_0xb4e6c9,_0x4cae64['options']);var _0x9b26e8={'where':_0xb4e6c9['where']};return db[_0xaf2d('0x3e')]['count'](_0x9b26e8)['then'](function(_0x3a4602){_0x3a8f40[_0xaf2d('0x2d')]=_0x3a4602;if(_0x4cae64['query'][_0xaf2d('0x53')]){_0xb4e6c9[_0xaf2d('0x54')]=[{'all':!![]}];}return db[_0xaf2d('0x3e')]['findAll'](_0xb4e6c9);})[_0xaf2d('0x1e')](function(_0x332e9b){_0x3a8f40[_0xaf2d('0x55')]=_0x332e9b;return _0x3a8f40;})[_0xaf2d('0x1e')](respondWithFilteredResult(_0x38d00c,_0xb4e6c9))['catch'](handleError(_0x38d00c,null));};exports['show']=function(_0x80b0fb,_0x1ee8d8){var _0x553f69={'raw':![],'where':{'id':_0x80b0fb[_0xaf2d('0x56')]['id']},'include':[{'model':db[_0xaf2d('0x3c')],'as':'mandatoryDispositionPause'}]},_0x26e74e={};_0x26e74e['model']=_[_0xaf2d('0x45')](db[_0xaf2d('0x3e')]['rawAttributes']);_0x26e74e['query']=_[_0xaf2d('0x45')](_0x80b0fb[_0xaf2d('0x44')]);_0x26e74e['filters']=_[_0xaf2d('0x46')](_0x26e74e[_0xaf2d('0x42')],_0x26e74e[_0xaf2d('0x44')]);_0x553f69[_0xaf2d('0x48')]=_[_0xaf2d('0x46')](_0x26e74e[_0xaf2d('0x42')],qs[_0xaf2d('0x47')](_0x80b0fb[_0xaf2d('0x44')]['fields']));_0x553f69[_0xaf2d('0x48')]=_0x553f69[_0xaf2d('0x48')][_0xaf2d('0x49')]?_0x553f69['attributes']:_0x26e74e[_0xaf2d('0x42')];if(_0x80b0fb['query']['includeAll']){_0x553f69[_0xaf2d('0x54')]=[{'all':!![]}];}_0x553f69=_[_0xaf2d('0x50')]({},_0x553f69,_0x80b0fb[_0xaf2d('0x57')]);return db[_0xaf2d('0x3e')]['find'](_0x553f69)['then'](handleEntityNotFound(_0x1ee8d8,null))[_0xaf2d('0x1e')](respondWithResult(_0x1ee8d8,null))[_0xaf2d('0x29')](handleError(_0x1ee8d8,null));};exports['create']=function(_0x456f67,_0x4579e8){return db[_0xaf2d('0x3e')][_0xaf2d('0x58')](_0x456f67[_0xaf2d('0x59')],{})[_0xaf2d('0x1e')](function(_0x342a31){var _0x32869f=_0x456f67['user'][_0xaf2d('0x5a')]({'plain':!![]});if(!_0x32869f)throw new Error(_0xaf2d('0x5b'));if(_0x32869f[_0xaf2d('0x5c')]===_0xaf2d('0x5d')){var _0x428fe7=_0x342a31['get']({'plain':!![]});var _0x29f277=_0xaf2d('0x37');return db['UserProfileSection'][_0xaf2d('0x5e')]({'where':{'name':_0x29f277,'userProfileId':_0x32869f[_0xaf2d('0x5f')]},'raw':!![]})[_0xaf2d('0x1e')](function(_0xd82d04){if(_0xd82d04&&_0xd82d04['autoAssociation']===0x0){return db[_0xaf2d('0x38')][_0xaf2d('0x58')]({'name':_0x428fe7[_0xaf2d('0x39')],'resourceId':_0x428fe7['id'],'type':_0xd82d04[_0xaf2d('0x39')],'sectionId':_0xd82d04['id']},{})[_0xaf2d('0x1e')](function(){return _0x342a31;});}else{return _0x342a31;}})[_0xaf2d('0x29')](function(_0x187fb4){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x187fb4);throw _0x187fb4;});}return _0x342a31;})[_0xaf2d('0x1e')](respondWithResult(_0x4579e8,0xc9))['catch'](handleError(_0x4579e8,null));};exports['update']=function(_0x28ba0c,_0x5a31bf){if(_0x28ba0c[_0xaf2d('0x59')]['id']){delete _0x28ba0c['body']['id'];}return db[_0xaf2d('0x3e')][_0xaf2d('0x5e')]({'where':{'id':_0x28ba0c[_0xaf2d('0x56')]['id']},'include':[{'model':db[_0xaf2d('0x3c')],'as':_0xaf2d('0x3d')}]})[_0xaf2d('0x1e')](handleEntityNotFound(_0x5a31bf,null))[_0xaf2d('0x1e')](saveUpdates(_0x28ba0c[_0xaf2d('0x59')],null))[_0xaf2d('0x1e')](respondWithResult(_0x5a31bf,null))[_0xaf2d('0x29')](handleError(_0x5a31bf,null));};exports[_0xaf2d('0x36')]=function(_0x1cd06f,_0x21c0bc){return db[_0xaf2d('0x3e')][_0xaf2d('0x5e')]({'where':{'id':_0x1cd06f[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x21c0bc,null))[_0xaf2d('0x1e')](removeEntity(_0x21c0bc,null))[_0xaf2d('0x29')](handleError(_0x21c0bc,null));};exports['describe']=function(_0x213d23,_0x1716d2){return db[_0xaf2d('0x3e')][_0xaf2d('0x60')]()[_0xaf2d('0x1e')](respondWithResult(_0x1716d2,null))[_0xaf2d('0x29')](handleError(_0x1716d2,null));};exports[_0xaf2d('0x61')]=function(_0x1b54a6,_0x8da117,_0x7c6dcc){if(_0x1b54a6[_0xaf2d('0x59')]['id']){delete _0x1b54a6['body']['id'];}return db['OpenchannelAccount']['find']({'where':{'id':_0x1b54a6[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x8da117,null))[_0xaf2d('0x1e')](function(_0x4f45d4){if(_0x4f45d4){_0x1b54a6[_0xaf2d('0x59')][_0xaf2d('0x62')]=_0x4f45d4['id'];return db['Disposition'][_0xaf2d('0x58')](_0x1b54a6[_0xaf2d('0x59')]);}})['then'](respondWithResult(_0x8da117,null))[_0xaf2d('0x29')](handleError(_0x8da117,null));};exports[_0xaf2d('0x63')]=function(_0x4b4540,_0x2ddf98,_0x156644){var _0x8b02f3={'raw':![],'where':{}};var _0xa3392e={};var _0x1d18c7={'count':0x0,'rows':[]};return db[_0xaf2d('0x3e')]['findOne']({'where':{'id':_0x4b4540[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x2ddf98,null))['then'](function(_0x256642){if(_0x256642){_0xa3392e['model']=_['keys'](db['Disposition'][_0xaf2d('0x3f')]);_0xa3392e['query']=_[_0xaf2d('0x45')](_0x4b4540['query']);_0xa3392e['filters']=_['intersection'](_0xa3392e['model'],_0xa3392e[_0xaf2d('0x44')]);_0x8b02f3[_0xaf2d('0x48')]=_['intersection'](_0xa3392e['model'],qs[_0xaf2d('0x47')](_0x4b4540['query'][_0xaf2d('0x47')]));_0x8b02f3[_0xaf2d('0x48')]=_0x8b02f3[_0xaf2d('0x48')][_0xaf2d('0x49')]?_0x8b02f3[_0xaf2d('0x48')]:_0xa3392e[_0xaf2d('0x42')];if(!_0x4b4540[_0xaf2d('0x44')][_0xaf2d('0x64')](_0xaf2d('0x4a'))){_0x8b02f3[_0xaf2d('0x2f')]=qs['limit'](_0x4b4540[_0xaf2d('0x44')][_0xaf2d('0x2f')]);_0x8b02f3[_0xaf2d('0x2e')]=qs[_0xaf2d('0x2e')](_0x4b4540[_0xaf2d('0x44')][_0xaf2d('0x2e')]);}_0x8b02f3[_0xaf2d('0x65')]=qs[_0xaf2d('0x4b')](_0x4b4540['query'][_0xaf2d('0x4b')]);_0x8b02f3[_0xaf2d('0x4f')]=qs[_0xaf2d('0x4c')](_[_0xaf2d('0x4d')](_0x4b4540[_0xaf2d('0x44')],_0xa3392e[_0xaf2d('0x4c')]));_0x8b02f3['where']['OpenchannelAccountId']=_0x256642['id'];if(_0x4b4540[_0xaf2d('0x44')][_0xaf2d('0x4e')]){_0x8b02f3[_0xaf2d('0x4f')]=_[_0xaf2d('0x50')](_0x8b02f3['where'],{'$or':_['map'](_0x8b02f3[_0xaf2d('0x48')],function(_0x372430){var _0x2ff7bc={};_0x2ff7bc[_0x372430]={'$like':'%'+_0x4b4540[_0xaf2d('0x44')][_0xaf2d('0x4e')]+'%'};return _0x2ff7bc;})});}_0x8b02f3=_['merge']({},_0x8b02f3,_0x4b4540[_0xaf2d('0x57')]);return db[_0xaf2d('0x66')][_0xaf2d('0x2d')]({'where':_0x8b02f3['where']})['then'](function(_0xbe4135){_0x1d18c7['count']=_0xbe4135;if(_0x4b4540['query']['includeAll']){_0x8b02f3['include']=[{'all':!![]}];}return db['Disposition']['findAll'](_0x8b02f3);})[_0xaf2d('0x1e')](function(_0x4e7040){_0x1d18c7[_0xaf2d('0x55')]=_0x4e7040;return _0x1d18c7;});}})[_0xaf2d('0x1e')](respondWithFilteredResult(_0x2ddf98,_0x8b02f3))[_0xaf2d('0x29')](handleError(_0x2ddf98,null));};exports[_0xaf2d('0x67')]=function(_0x3b5787,_0x27f237,_0x242f46){return db['OpenchannelAccount']['find']({'where':{'id':_0x3b5787[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x27f237,null))[_0xaf2d('0x1e')](function(_0x1f2ace){if(_0x1f2ace){return _0x1f2ace[_0xaf2d('0x67')](_0x3b5787['query'][_0xaf2d('0x68')]);}})[_0xaf2d('0x1e')](respondWithStatusCode(_0x27f237,null))[_0xaf2d('0x29')](handleError(_0x27f237,null));};exports['addAnswer']=function(_0xb3f2ad,_0x329c4e,_0x31547d){if(_0xb3f2ad[_0xaf2d('0x59')]['id']){delete _0xb3f2ad[_0xaf2d('0x59')]['id'];}return db[_0xaf2d('0x3e')][_0xaf2d('0x5e')]({'where':{'id':_0xb3f2ad[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x329c4e,null))[_0xaf2d('0x1e')](function(_0x52abf1){if(_0x52abf1){_0xb3f2ad['body']['OpenchannelAccountId']=_0x52abf1['id'];return db[_0xaf2d('0x69')][_0xaf2d('0x58')](_0xb3f2ad['body']);}})['then'](respondWithResult(_0x329c4e,null))[_0xaf2d('0x29')](handleError(_0x329c4e,null));};exports['getAnswers']=function(_0x45427c,_0x47ed28,_0x1e0475){var _0x25799a={'raw':![],'where':{}};var _0x19fdc3={};var _0x41a26d={'count':0x0,'rows':[]};return db[_0xaf2d('0x3e')][_0xaf2d('0x6a')]({'where':{'id':_0x45427c[_0xaf2d('0x56')]['id']}})['then'](handleEntityNotFound(_0x47ed28,null))['then'](function(_0x2a509e){if(_0x2a509e){_0x19fdc3[_0xaf2d('0x42')]=_['keys'](db[_0xaf2d('0x69')]['rawAttributes']);_0x19fdc3[_0xaf2d('0x44')]=_[_0xaf2d('0x45')](_0x45427c['query']);_0x19fdc3[_0xaf2d('0x4c')]=_[_0xaf2d('0x46')](_0x19fdc3['model'],_0x19fdc3[_0xaf2d('0x44')]);_0x25799a[_0xaf2d('0x48')]=_[_0xaf2d('0x46')](_0x19fdc3['model'],qs[_0xaf2d('0x47')](_0x45427c[_0xaf2d('0x44')][_0xaf2d('0x47')]));_0x25799a[_0xaf2d('0x48')]=_0x25799a[_0xaf2d('0x48')][_0xaf2d('0x49')]?_0x25799a[_0xaf2d('0x48')]:_0x19fdc3[_0xaf2d('0x42')];if(!_0x45427c['query']['hasOwnProperty'](_0xaf2d('0x4a'))){_0x25799a[_0xaf2d('0x2f')]=qs['limit'](_0x45427c[_0xaf2d('0x44')][_0xaf2d('0x2f')]);_0x25799a[_0xaf2d('0x2e')]=qs[_0xaf2d('0x2e')](_0x45427c['query']['offset']);}_0x25799a['order']=qs['sort'](_0x45427c['query'][_0xaf2d('0x4b')]);_0x25799a['where']=qs[_0xaf2d('0x4c')](_[_0xaf2d('0x4d')](_0x45427c[_0xaf2d('0x44')],_0x19fdc3[_0xaf2d('0x4c')]));_0x25799a[_0xaf2d('0x4f')][_0xaf2d('0x6b')]=_0x2a509e['id'];if(_0x45427c['query'][_0xaf2d('0x4e')]){_0x25799a[_0xaf2d('0x4f')]=_['merge'](_0x25799a[_0xaf2d('0x4f')],{'$or':_[_0xaf2d('0x43')](_0x25799a[_0xaf2d('0x48')],function(_0x29af68){var _0x3d439b={};_0x3d439b[_0x29af68]={'$like':'%'+_0x45427c[_0xaf2d('0x44')][_0xaf2d('0x4e')]+'%'};return _0x3d439b;})});}_0x25799a=_[_0xaf2d('0x50')]({},_0x25799a,_0x45427c[_0xaf2d('0x57')]);return db[_0xaf2d('0x69')]['count']({'where':_0x25799a[_0xaf2d('0x4f')]})[_0xaf2d('0x1e')](function(_0x464066){_0x41a26d[_0xaf2d('0x2d')]=_0x464066;if(_0x45427c[_0xaf2d('0x44')]['includeAll']){_0x25799a[_0xaf2d('0x54')]=[{'all':!![]}];}return db[_0xaf2d('0x69')]['findAll'](_0x25799a);})[_0xaf2d('0x1e')](function(_0x20ec88){_0x41a26d[_0xaf2d('0x55')]=_0x20ec88;return _0x41a26d;});}})[_0xaf2d('0x1e')](respondWithFilteredResult(_0x47ed28,_0x25799a))['catch'](handleError(_0x47ed28,null));};exports[_0xaf2d('0x6c')]=function(_0x5efaa6,_0x12e8e8,_0x5d2514){return db[_0xaf2d('0x3e')]['find']({'where':{'id':_0x5efaa6['params']['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x12e8e8,null))['then'](function(_0x528f6a){if(_0x528f6a){return _0x528f6a[_0xaf2d('0x6c')](_0x5efaa6['query'][_0xaf2d('0x68')]);}})['then'](respondWithStatusCode(_0x12e8e8,null))['catch'](handleError(_0x12e8e8,null));};exports[_0xaf2d('0x6d')]=function(_0x27bd60,_0x55b492,_0x300fc6){var _0x4c199f={'body':_0x27bd60[_0xaf2d('0x59')],'channel':'openchannel'};var _0x411c93=[];var _0xbaae34=[];var _0xe18304={};var _0xe0c0ac=![];return db[_0xaf2d('0x6e')][_0xaf2d('0x60')]()[_0xaf2d('0x1e')](function(_0x42a496){if(!_0x42a496){throw new db[(_0xaf2d('0x1b'))]['ValidationError'](_0xaf2d('0x6f'));}_0x411c93=_['difference'](_[_0xaf2d('0x45')](_0x42a496),[_0xaf2d('0x70'),'updatedAt']);_0xbaae34=_['difference'](_[_0xaf2d('0x45')](_0x42a496),[_0xaf2d('0x70'),_0xaf2d('0x71'),'CompanyId',_0xaf2d('0x72')]);if(_0x27bd60['body']['id']){delete _0x27bd60[_0xaf2d('0x59')]['id'];}if(_[_0xaf2d('0x73')](_0x27bd60['body'][_0xaf2d('0x74')])){throw new db['Sequelize'][(_0xaf2d('0x1c'))](_0xaf2d('0x75'));}if(_[_0xaf2d('0x73')](_0x27bd60['body'][_0xaf2d('0x59')])||_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x59')]===''){throw new db['Sequelize']['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x27bd60[_0xaf2d('0x59')]['mapKey'])){throw new db[(_0xaf2d('0x1b'))][(_0xaf2d('0x1c'))](_0xaf2d('0x76')+_0xbaae34);}if(!_[_0xaf2d('0x77')](_0xbaae34,_0x27bd60[_0xaf2d('0x59')]['mapKey'])){throw new db['Sequelize'][(_0xaf2d('0x1c'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0xbaae34);}_0xe18304[_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x78')]]=_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x74')];})[_0xaf2d('0x1e')](function(){return db[_0xaf2d('0x3e')]['find']({'where':{'id':_0x27bd60[_0xaf2d('0x56')]['id']},'include':[{'model':db[_0xaf2d('0x79')],'as':_0xaf2d('0x7a'),'include':[{'model':db[_0xaf2d('0x6e')],'as':_0xaf2d('0x7b'),'where':_0xe18304,'limit':0x1,'order':[[_0xaf2d('0x71'),_0xaf2d('0x7c')]]}]},{'model':db[_0xaf2d('0x7d')],'as':_0xaf2d('0x7e')}]});})[_0xaf2d('0x1e')](handleEntityNotFound(_0x55b492,null))[_0xaf2d('0x1e')](function(_0x59d279){if(_0x59d279&&_0x59d279[_0xaf2d('0x7a')]){_0x4c199f[_0xaf2d('0x7f')]=_0x59d279;_0x4c199f[_0xaf2d('0x80')]=_0x59d279['Applications'];_0x4c199f[_0xaf2d('0x81')]=_0x59d279['List'];_0x4c199f[_0xaf2d('0x80')]=_[_0xaf2d('0x82')](_0x4c199f[_0xaf2d('0x80')],[_0xaf2d('0x83')],[_0xaf2d('0x84')]);if(_0x4c199f[_0xaf2d('0x7f')][_0xaf2d('0x7e')]){delete _0x4c199f['account'][_0xaf2d('0x7e')];}if(_0x4c199f[_0xaf2d('0x7f')][_0xaf2d('0x7a')]&&_0x4c199f['account']['List']['Contacts'][_0xaf2d('0x49')]){return _0x4c199f['account'][_0xaf2d('0x7a')][_0xaf2d('0x7b')][0x0];}var _0x3a0742=_[_0xaf2d('0x16')](_0x27bd60[_0xaf2d('0x59')],{'firstName':_0x27bd60[_0xaf2d('0x59')]['from'],'ListId':_0x59d279['ListId']});_0x3a0742[_0x27bd60[_0xaf2d('0x59')]['mapKey']]=_0x27bd60['body'][_0xaf2d('0x74')];return db[_0xaf2d('0x6e')][_0xaf2d('0x58')](_0x3a0742,{'fields':_0x411c93,'raw':!![]});}})['then'](handleEntityNotFound(_0x55b492,null))['then'](function(_0x12cbb4){_0x4c199f[_0xaf2d('0x85')]=_0x12cbb4;if(_0x12cbb4){var _0xfd6611={'ContactId':_0x12cbb4['id'],'OpenchannelAccountId':_0x27bd60['params']['id'],'from':(_0x12cbb4[_0xaf2d('0x86')]||'')+'\x20'+(_0x12cbb4['lastName']||'')};var _0xd25a52={'OpenchannelAccountId':_0x27bd60[_0xaf2d('0x56')]['id'],'closed':![]};if(_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x87')]){_0xd25a52[_0xaf2d('0x87')]=_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x87')];return db[_0xaf2d('0x88')]['find']({'where':_0xd25a52})[_0xaf2d('0x1e')](function(_0x3f472a){if(_0x3f472a){return[_0x3f472a,![]];}_0xfd6611[_0xaf2d('0x87')]=_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x87')];_0xfd6611[_0xaf2d('0x89')]=_0x27bd60[_0xaf2d('0x59')]['externalUrl'];return db[_0xaf2d('0x88')]['create'](_0xfd6611)[_0xaf2d('0x1e')](function(_0x3a2c0c){return[_0x3a2c0c,!![]];});});}else{_0xd25a52[_0xaf2d('0x87')]=null;}_0xd25a52[_0xaf2d('0x8a')]=_0x12cbb4['id'];return db['OpenchannelInteraction']['find']({'where':_0xd25a52})[_0xaf2d('0x1e')](function(_0x18ce32){if(_0x18ce32){return[_0x18ce32,![]];}return db[_0xaf2d('0x88')]['create'](_0xfd6611)[_0xaf2d('0x1e')](function(_0x14c9fd){return[_0x14c9fd,!![]];});});}})[_0xaf2d('0x8b')](function(_0x397d56,_0x17af3e){if(_0x397d56){_0xe0c0ac=_0x17af3e;if(!_0x17af3e){var _0x38fe4c={'from':(_0x4c199f[_0xaf2d('0x85')][_0xaf2d('0x86')]||'')+'\x20'+(_0x4c199f[_0xaf2d('0x85')]['lastName']||'')};if(_0x27bd60[_0xaf2d('0x59')]['threadId']&&_0x27bd60[_0xaf2d('0x59')]['messageId']&&_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x87')]!=_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x8c')]){_0x38fe4c['threadId']=_0x27bd60['body'][_0xaf2d('0x8c')];}return _0x397d56['update'](_0x38fe4c);}else{return _0x397d56;}}})[_0xaf2d('0x1e')](function(_0x418f7f){_0x4c199f['interaction']=_0x418f7f['get']({'plain':!![]});_0x4c199f[_0xaf2d('0x8d')]['created']=_0xe0c0ac;if(_0x4c199f[_0xaf2d('0x8d')][_0xaf2d('0x8e')]){if(_0x4c199f['account'][_0xaf2d('0x8f')]){_0x4c199f[_0xaf2d('0x80')][_0xaf2d('0x90')]({'id':0x0,'priority':_0x4c199f[_0xaf2d('0x80')][_0xaf2d('0x49')]+0x1,'app':_0xaf2d('0x91'),'appdata':_0xaf2d('0x92'),'interval':_0xaf2d('0x93')});}}return db[_0xaf2d('0x94')][_0xaf2d('0x58')]({'body':_0x27bd60[_0xaf2d('0x59')][_0xaf2d('0x59')],'OpenchannelAccountId':_0x27bd60[_0xaf2d('0x56')]['id'],'OpenchannelInteractionId':_0x418f7f['id'],'direction':'in','ContactId':_0x4c199f['contact']['id'],'AttachmentId':_0x27bd60[_0xaf2d('0x59')]['AttachmentId']});})[_0xaf2d('0x1e')](function(_0x599cbb){_0x4c199f[_0xaf2d('0x27')]=_0x599cbb;if(_0x4c199f[_0xaf2d('0x8d')]['UserId']){return db[_0xaf2d('0x95')][_0xaf2d('0x5e')]({'attributes':['id',_0xaf2d('0x39')],'where':{'id':_0x4c199f[_0xaf2d('0x8d')]['UserId']}})[_0xaf2d('0x1e')](function(_0x56e15e){if(_0x56e15e){_0x4c199f[_0xaf2d('0x80')]['unshift']({'id':0x0,'priority':0x0,'app':_0xaf2d('0x96'),'appdata':_0x56e15e[_0xaf2d('0x39')]+','+(_0x4c199f[_0xaf2d('0x7f')]['waitForTheAssignedAgent']||0xa),'interval':_0xaf2d('0x93')});_0x4c199f['forcedOwnership']=![];}return respondWithRpcPromise('Start','startRouting',_0x4c199f);});}return respondWithRpcPromise(_0xaf2d('0x97'),_0xaf2d('0x98'),_0x4c199f);})[_0xaf2d('0x1e')](function(_0x563f23){respondWithRpcPromise(_0xaf2d('0x99'),_0xaf2d('0x99'),{'event':'notify','message':_0x563f23},client9002);return _0x563f23;})[_0xaf2d('0x1e')](respondWithResult(_0x55b492,null))[_0xaf2d('0x29')](handleError(_0x55b492,null));};exports[_0xaf2d('0x9a')]=function(_0x26608c,_0x321a45,_0xb4d6b){return db[_0xaf2d('0x3e')][_0xaf2d('0x6a')]({'where':{'id':_0x26608c['params']['id']}})['then'](handleEntityNotFound(_0x321a45,null))[_0xaf2d('0x1e')](function(_0x13788c){if(_0x13788c){return db['sequelize']['transaction'](function(_0x3eab58){return db[_0xaf2d('0x7d')][_0xaf2d('0x36')]({'where':{'OpenchannelAccountId':_0x26608c[_0xaf2d('0x56')]['id']},'transaction':_0x3eab58})[_0xaf2d('0x1e')](function(_0x35e810){var _0x529510=_[_0xaf2d('0x43')](_0x26608c[_0xaf2d('0x59')],function(_0x36c025){_0x36c025[_0xaf2d('0x6b')]=_0x26608c[_0xaf2d('0x56')]['id'];return _0x36c025;});return db[_0xaf2d('0x7d')][_0xaf2d('0x9b')](_0x529510,{'transaction':_0x3eab58});});})[_0xaf2d('0x1e')](function(){return db[_0xaf2d('0x7d')][_0xaf2d('0x9c')]({'where':{'OpenchannelAccountId':_0x26608c[_0xaf2d('0x56')]['id']},'order':'priority'});});}})[_0xaf2d('0x1e')](respondWithResult(_0x321a45,null))[_0xaf2d('0x29')](handleError(_0x321a45,null));};exports[_0xaf2d('0x9d')]=function(_0x5beb55,_0x48085d,_0x56bd0c){var _0x5e5980={};var _0x2b2ff3={};var _0x5ae510;var _0x54725e;return db[_0xaf2d('0x3e')]['findOne']({'where':{'id':_0x5beb55['params']['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x48085d,null))[_0xaf2d('0x1e')](function(_0x41017a){if(_0x41017a){_0x5ae510=_0x41017a;_0x2b2ff3[_0xaf2d('0x42')]=_[_0xaf2d('0x45')](db[_0xaf2d('0x7d')][_0xaf2d('0x3f')]);_0x2b2ff3[_0xaf2d('0x44')]=_[_0xaf2d('0x45')](_0x5beb55[_0xaf2d('0x44')]);_0x2b2ff3[_0xaf2d('0x4c')]=_['intersection'](_0x2b2ff3['model'],_0x2b2ff3[_0xaf2d('0x44')]);_0x5e5980[_0xaf2d('0x48')]=_[_0xaf2d('0x46')](_0x2b2ff3[_0xaf2d('0x42')],qs[_0xaf2d('0x47')](_0x5beb55['query'][_0xaf2d('0x47')]));_0x5e5980[_0xaf2d('0x48')]=_0x5e5980['attributes']['length']?_0x5e5980[_0xaf2d('0x48')]:_0x2b2ff3[_0xaf2d('0x42')];_0x5e5980[_0xaf2d('0x65')]=qs[_0xaf2d('0x4b')](_0x5beb55[_0xaf2d('0x44')]['sort']);_0x5e5980['where']=qs['filters'](_[_0xaf2d('0x4d')](_0x5beb55['query'],_0x2b2ff3[_0xaf2d('0x4c')]));if(_0x5beb55[_0xaf2d('0x44')][_0xaf2d('0x4e')]){_0x5e5980[_0xaf2d('0x4f')]=_[_0xaf2d('0x50')](_0x5e5980[_0xaf2d('0x4f')],{'$or':_[_0xaf2d('0x43')](_0x5e5980[_0xaf2d('0x48')],function(_0x395aa1){var _0x441084={};_0x441084[_0x395aa1]={'$like':'%'+_0x5beb55['query'][_0xaf2d('0x4e')]+'%'};return _0x441084;})});}_0x5e5980=_[_0xaf2d('0x50')]({},_0x5e5980,_0x5beb55[_0xaf2d('0x57')]);return _0x5ae510[_0xaf2d('0x9d')](_0x5e5980);}})['then'](function(_0x58bd63){if(_0x58bd63){_0x54725e=_0x58bd63[_0xaf2d('0x49')];if(!_0x5beb55[_0xaf2d('0x44')][_0xaf2d('0x64')](_0xaf2d('0x4a'))){_0x5e5980[_0xaf2d('0x2f')]=qs['limit'](_0x5beb55[_0xaf2d('0x44')]['limit']);_0x5e5980[_0xaf2d('0x2e')]=qs['offset'](_0x5beb55['query']['offset']);}return _0x5ae510[_0xaf2d('0x9d')](_0x5e5980);}})['then'](function(_0x23019c){if(_0x23019c){return _0x23019c?{'count':_0x54725e,'rows':_0x23019c}:null;}})['then'](respondWithResult(_0x48085d,null))['catch'](handleError(_0x48085d,null));};exports[_0xaf2d('0x9e')]=function(_0x57f52e,_0x2c1f35,_0x38b246){var _0x38ead8={'raw':![],'where':{}};var _0x3f58ea={};var _0x435a9d={'count':0x0,'rows':[]};return db[_0xaf2d('0x3e')][_0xaf2d('0x6a')]({'where':{'id':_0x57f52e['params']['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x2c1f35,null))[_0xaf2d('0x1e')](function(_0x324263){if(_0x324263){_0x3f58ea[_0xaf2d('0x42')]=_['keys'](db[_0xaf2d('0x88')][_0xaf2d('0x3f')]);_0x3f58ea[_0xaf2d('0x44')]=_[_0xaf2d('0x45')](_0x57f52e[_0xaf2d('0x44')]);_0x3f58ea[_0xaf2d('0x4c')]=_[_0xaf2d('0x46')](_0x3f58ea[_0xaf2d('0x42')],_0x3f58ea[_0xaf2d('0x44')]);_0x38ead8[_0xaf2d('0x48')]=_[_0xaf2d('0x46')](_0x3f58ea[_0xaf2d('0x42')],qs[_0xaf2d('0x47')](_0x57f52e[_0xaf2d('0x44')][_0xaf2d('0x47')]));_0x38ead8[_0xaf2d('0x48')]=_0x38ead8['attributes'][_0xaf2d('0x49')]?_0x38ead8[_0xaf2d('0x48')]:_0x3f58ea[_0xaf2d('0x42')];if(!_0x57f52e[_0xaf2d('0x44')]['hasOwnProperty'](_0xaf2d('0x4a'))){_0x38ead8[_0xaf2d('0x2f')]=qs['limit'](_0x57f52e[_0xaf2d('0x44')]['limit']);_0x38ead8[_0xaf2d('0x2e')]=qs[_0xaf2d('0x2e')](_0x57f52e['query'][_0xaf2d('0x2e')]);}_0x38ead8[_0xaf2d('0x65')]=qs[_0xaf2d('0x4b')](_0x57f52e[_0xaf2d('0x44')][_0xaf2d('0x4b')]);_0x38ead8[_0xaf2d('0x4f')]=qs[_0xaf2d('0x4c')](_[_0xaf2d('0x4d')](_0x57f52e[_0xaf2d('0x44')],_0x3f58ea['filters']));_0x38ead8['where'][_0xaf2d('0x6b')]=_0x324263['id'];if(_0x57f52e['query'][_0xaf2d('0x4e')]){_0x38ead8[_0xaf2d('0x4f')]=_['merge'](_0x38ead8['where'],{'$or':_['map'](_0x38ead8[_0xaf2d('0x48')],function(_0x2f202d){var _0x21724b={};_0x21724b[_0x2f202d]={'$like':'%'+_0x57f52e[_0xaf2d('0x44')][_0xaf2d('0x4e')]+'%'};return _0x21724b;})});}_0x38ead8=_[_0xaf2d('0x50')]({},_0x38ead8,_0x57f52e['options']);return db['OpenchannelInteraction'][_0xaf2d('0x2d')]({'where':_0x38ead8[_0xaf2d('0x4f')]})[_0xaf2d('0x1e')](function(_0x470b71){_0x435a9d[_0xaf2d('0x2d')]=_0x470b71;if(_0x57f52e[_0xaf2d('0x44')]['includeAll']){_0x38ead8['include']=[{'model':db[_0xaf2d('0x6e')],'as':_0xaf2d('0x9f'),'required':![]},{'model':db['User'],'as':_0xaf2d('0xa0'),'attributes':['name',_0xaf2d('0xa1'),_0xaf2d('0xa2')],'required':![]},{'model':db[_0xaf2d('0xa3')],'as':_0xaf2d('0xa4'),'attributes':['id','name',_0xaf2d('0xa5')],'where':_0x57f52e[_0xaf2d('0x44')][_0xaf2d('0xa6')]?{'id':_0x57f52e[_0xaf2d('0x44')][_0xaf2d('0xa6')]}:undefined,'required':_0x57f52e[_0xaf2d('0x44')]['tag']?!![]:![]}];}return db[_0xaf2d('0x88')][_0xaf2d('0xa7')](_0x38ead8);})[_0xaf2d('0x1e')](function(_0x3689de){_0x435a9d[_0xaf2d('0x55')]=_0x3689de;return _0x435a9d;});}})['then'](respondWithFilteredResult(_0x2c1f35,_0x38ead8))[_0xaf2d('0x29')](handleError(_0x2c1f35,null));};exports[_0xaf2d('0xa8')]=function(_0x4bcccf,_0xe3bf7,_0xbf49f7){return db['OpenchannelAccount']['find']({'where':{'id':_0x4bcccf[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0xe3bf7,null))['then'](function(_0x484bed){if(_0x484bed){return _0x484bed['addAgents'](_0x4bcccf['body']['ids'],_[_0xaf2d('0xa9')](_0x4bcccf[_0xaf2d('0x59')],[_0xaf2d('0x68'),'id'])||{})[_0xaf2d('0x8b')](function(_0x5277dc){for(var _0x4acaa5=0x0;_0x4acaa5<_0x4bcccf['body'][_0xaf2d('0x68')][_0xaf2d('0x49')];_0x4acaa5+=0x1){socket[_0xaf2d('0xaa')](_0xaf2d('0xab'),{'UserId':_0x4bcccf[_0xaf2d('0x59')][_0xaf2d('0x68')][_0x4acaa5],'OpenchannelAccountId':_0x4bcccf['params']['id']});}return _0x5277dc;});}})[_0xaf2d('0x1e')](respondWithResult(_0xe3bf7,null))[_0xaf2d('0x29')](handleError(_0xe3bf7,null));};exports[_0xaf2d('0xac')]=function(_0x5ee7fc,_0x447176,_0x45120c){return db['OpenchannelAccount'][_0xaf2d('0x5e')]({'where':{'id':_0x5ee7fc[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x447176,null))['then'](function(_0x448fd2){if(_0x448fd2){return _0x448fd2[_0xaf2d('0xac')](_0x5ee7fc[_0xaf2d('0x44')][_0xaf2d('0x68')])['then'](function(){if(_['isArray'](_0x5ee7fc[_0xaf2d('0x44')][_0xaf2d('0x68')])){for(var _0x3fe351=0x0;_0x3fe351<_0x5ee7fc[_0xaf2d('0x44')][_0xaf2d('0x68')][_0xaf2d('0x49')];_0x3fe351+=0x1){socket[_0xaf2d('0xaa')](_0xaf2d('0xad'),{'UserId':Number(_0x5ee7fc[_0xaf2d('0x44')][_0xaf2d('0x68')][_0x3fe351]),'OpenchannelAccountId':Number(_0x5ee7fc[_0xaf2d('0x56')]['id'])});}}else{socket['emit']('userOpenchannelAccount:remove',{'UserId':Number(_0x5ee7fc[_0xaf2d('0x44')]['ids']),'OpenchannelAccountId':Number(_0x5ee7fc[_0xaf2d('0x56')]['id'])});}});}})['then'](respondWithStatusCode(_0x447176,null))[_0xaf2d('0x29')](handleError(_0x447176,null));};exports[_0xaf2d('0xae')]=function(_0x942c4b,_0x3c4bb1,_0x49eb0f){var _0x3cfb1a={};var _0x47507b={};var _0x3d9091;var _0x19825b;return db['OpenchannelAccount'][_0xaf2d('0x6a')]({'where':{'id':_0x942c4b[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x3c4bb1,null))['then'](function(_0x5b0493){if(_0x5b0493){_0x3d9091=_0x5b0493;_0x47507b[_0xaf2d('0x42')]=_['keys'](db[_0xaf2d('0x95')]['rawAttributes']);_0x47507b['query']=_['keys'](_0x942c4b[_0xaf2d('0x44')]);_0x47507b[_0xaf2d('0x4c')]=_[_0xaf2d('0x46')](_0x47507b[_0xaf2d('0x42')],_0x47507b['query']);_0x3cfb1a[_0xaf2d('0x48')]=_['intersection'](_0x47507b[_0xaf2d('0x42')],qs[_0xaf2d('0x47')](_0x942c4b['query'][_0xaf2d('0x47')]));_0x3cfb1a[_0xaf2d('0x48')]=_0x3cfb1a['attributes']['length']?_0x3cfb1a[_0xaf2d('0x48')]:_0x47507b[_0xaf2d('0x42')];_0x3cfb1a[_0xaf2d('0x65')]=qs[_0xaf2d('0x4b')](_0x942c4b[_0xaf2d('0x44')]['sort']);_0x3cfb1a[_0xaf2d('0x4f')]=qs[_0xaf2d('0x4c')](_[_0xaf2d('0x4d')](_0x942c4b[_0xaf2d('0x44')],_0x47507b['filters']));if(_0x942c4b[_0xaf2d('0x44')][_0xaf2d('0x4e')]){_0x3cfb1a[_0xaf2d('0x4f')]=_[_0xaf2d('0x50')](_0x3cfb1a[_0xaf2d('0x4f')],{'$or':_[_0xaf2d('0x43')](_0x3cfb1a[_0xaf2d('0x48')],function(_0x2eeaaf){var _0x54fcad={};_0x54fcad[_0x2eeaaf]={'$like':'%'+_0x942c4b['query'][_0xaf2d('0x4e')]+'%'};return _0x54fcad;})});}_0x3cfb1a=_['merge']({},_0x3cfb1a,_0x942c4b[_0xaf2d('0x57')]);return _0x3d9091[_0xaf2d('0xae')](_0x3cfb1a);}})['then'](function(_0x22943c){if(_0x22943c){_0x19825b=_0x22943c[_0xaf2d('0x49')];if(!_0x942c4b[_0xaf2d('0x44')]['hasOwnProperty'](_0xaf2d('0x4a'))){_0x3cfb1a[_0xaf2d('0x2f')]=qs[_0xaf2d('0x2f')](_0x942c4b[_0xaf2d('0x44')][_0xaf2d('0x2f')]);_0x3cfb1a[_0xaf2d('0x2e')]=qs[_0xaf2d('0x2e')](_0x942c4b['query'][_0xaf2d('0x2e')]);}return _0x3d9091[_0xaf2d('0xae')](_0x3cfb1a);}})['then'](function(_0x39fc74){if(_0x39fc74){return _0x39fc74?{'count':_0x19825b,'rows':_0x39fc74}:null;}})[_0xaf2d('0x1e')](respondWithResult(_0x3c4bb1,null))[_0xaf2d('0x29')](handleError(_0x3c4bb1,null));};exports['send']=function(_0x2a5209,_0x19730b,_0x1ac788){var _0x270b43,_0x94249d,_0x977286;if(_[_0xaf2d('0x73')](_0x2a5209[_0xaf2d('0x59')][_0xaf2d('0x59')])||_0x2a5209[_0xaf2d('0x59')][_0xaf2d('0x59')]===''){throw new db[(_0xaf2d('0x1b'))][(_0xaf2d('0x1c'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xaf2d('0x73')](_0x2a5209[_0xaf2d('0x59')]['to'])){}_0x270b43=_0x2a5209[_0xaf2d('0x59')]['to'];return db[_0xaf2d('0x3e')][_0xaf2d('0x6a')]({'where':{'id':_0x2a5209[_0xaf2d('0x56')]['id']}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x19730b,null))[_0xaf2d('0x1e')](function(_0x16e487){if(_0x16e487){return db['OpenchannelAccount'][_0xaf2d('0x5e')]({'where':{'id':_0x16e487['id']},'include':[{'model':db[_0xaf2d('0x79')],'as':'List','include':[{'model':db['CmContact'],'as':_0xaf2d('0x7b'),'where':{[_0x16e487[_0xaf2d('0x78')]]:_0x270b43},'limit':0x1,'order':[[_0xaf2d('0x71'),_0xaf2d('0x7c')]]}]}]})[_0xaf2d('0x1e')](handleEntityNotFound(_0x19730b,null))['then'](function(_0x2fd962){if(_0x2fd962&&_0x2fd962['List']){_0x94249d=_0x2fd962[_0xaf2d('0x5a')]({'plain':!![]});if(_0x94249d[_0xaf2d('0x7a')]&&_0x94249d['List'][_0xaf2d('0x7b')][_0xaf2d('0x49')]){return _0x94249d[_0xaf2d('0x7a')][_0xaf2d('0x7b')][0x0];}return db[_0xaf2d('0x6e')][_0xaf2d('0x58')](_[_0xaf2d('0x16')](_0x2a5209[_0xaf2d('0x59')],{'firstName':_0x270b43,[_0x2fd962[_0xaf2d('0x78')]]:_0x270b43,'phone':_0x270b43,'ListId':_0x94249d['ListId']}));}})[_0xaf2d('0x1e')](handleEntityNotFound(_0x19730b,null))[_0xaf2d('0x1e')](function(_0x4e7315){if(_0x4e7315){_0x977286=_0x4e7315;return db['OpenchannelInteraction'][_0xaf2d('0x5e')]({'where':{'ContactId':_0x977286['id'],'closed':![],'OpenchannelAccountId':_0x94249d['id']}})[_0xaf2d('0x1e')](function(_0x365477){if(_0x365477){return[_0x365477,![]];}return db[_0xaf2d('0x88')][_0xaf2d('0x58')]({'UserId':_0x2a5209[_0xaf2d('0x5d')]['id'],'ContactId':_0x977286['id'],'OpenchannelAccountId':_0x94249d['id'],'lastMsgDirection':_0xaf2d('0xaf'),'Messages':[_['merge'](_0x2a5209['body'],{'read':![],'body':_0x2a5209['body'][_0xaf2d('0x59')],'OpenchannelAccountId':_0x94249d['id'],'UserId':_0x2a5209[_0xaf2d('0x5d')]['id'],'ContactId':_0x977286['id']})]},{'include':[{'model':db[_0xaf2d('0x94')],'as':_0xaf2d('0xb0')}]})[_0xaf2d('0x1e')](function(_0x17eb67){return[_0x17eb67,!![]];});});}})['spread'](function(_0x51da7d,_0x421de2){if(_0x421de2){return _0x51da7d;}return db[_0xaf2d('0x94')][_0xaf2d('0x58')](_['merge'](_0x2a5209[_0xaf2d('0x59')],{'read':![],'body':_0x2a5209[_0xaf2d('0x59')]['body'],'OpenchannelAccountId':_0x94249d['id'],'OpenchannelInteractionId':_0x51da7d['id'],'UserId':_0x2a5209[_0xaf2d('0x5d')]['id'],'ContactId':_0x977286['id']}))[_0xaf2d('0x1e')](function(_0x101184){_0x51da7d[_0xaf2d('0xb1')][_0xaf2d('0xb0')]=[];_0x51da7d[_0xaf2d('0xb1')][_0xaf2d('0xb0')][_0xaf2d('0x90')](_0x101184[_0xaf2d('0xb1')]);return _0x51da7d;});});}})[_0xaf2d('0x1e')](respondWithResult(_0x19730b,null))[_0xaf2d('0x29')](handleError(_0x19730b,null));};
\ No newline at end of file
+var _0x98f9=['error','OpenchannelAccount,\x20%s,\x20%s','message','catch','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','OpenchannelAccounts','UserProfileResource','end','sendStatus','name','index','Pause','mandatoryDispositionPause','map','OpenchannelAccount','fieldName','type','model','query','filters','attributes','fields','hasOwnProperty','nolimit','order','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','show','params','keys','intersection','length','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','find','Disposition','getDispositions','findOne','rawAttributes','sort','OpenchannelAccountId','rows','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','notify','openchannel','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','includes','mapKey','CmContact','Contacts','DESC','Applications','List','account','applications','list','orderBy','ListId','contact','firstName','lastName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','messageId','interaction','created','autoclose','push','unmanaged','OpenchannelMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','addApplications','sequelize','transaction','OpenchannelApplication','bulkCreate','priority','getApplications','Contact','Owner','fullname','Tag','Tags','addAgents','omit','emit','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','send','CmList','Messages','dataValues','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./openchannelAccount.socket','register','jayson/promise','client','http','request','then','request\x20sent','stringify'];(function(_0x2f0b26,_0x5bae04){var _0x5aa5c6=function(_0x1d81e0){while(--_0x1d81e0){_0x2f0b26['push'](_0x2f0b26['shift']());}};_0x5aa5c6(++_0x5bae04);}(_0x98f9,0x150));var _0x998f=function(_0x3a2721,_0x10f711){_0x3a2721=_0x3a2721-0x0;var _0x33be8d=_0x98f9[_0x3a2721];return _0x33be8d;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x998f('0x0'));var rimraf=require(_0x998f('0x1'));var zipdir=require(_0x998f('0x2'));var jsonpatch=require(_0x998f('0x3'));var rp=require(_0x998f('0x4'));var moment=require('moment');var BPromise=require(_0x998f('0x5'));var Mustache=require(_0x998f('0x6'));var util=require(_0x998f('0x7'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x998f('0x8'));var squel=require(_0x998f('0x9'));var crypto=require(_0x998f('0xa'));var jsforce=require(_0x998f('0xb'));var deskjs=require(_0x998f('0xc'));var toCsv=require(_0x998f('0xd'));var querystring=require(_0x998f('0xe'));var Papa=require(_0x998f('0xf'));var Redis=require(_0x998f('0x10'));var authService=require(_0x998f('0x11'));var qs=require(_0x998f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x998f('0x13'))(_0x998f('0x14'));var utils=require(_0x998f('0x15'));var config=require(_0x998f('0x16'));var licenseUtil=require(_0x998f('0x17'));var db=require(_0x998f('0x18'))['db'];config['redis']=_[_0x998f('0x19')](config['redis'],{'host':_0x998f('0x1a'),'port':0x18eb});var socket=require(_0x998f('0x1b'))(new Redis(config[_0x998f('0x1c')]));require(_0x998f('0x1d'))[_0x998f('0x1e')](socket);var jayson=require(_0x998f('0x1f'));var client=jayson[_0x998f('0x20')][_0x998f('0x21')]({'port':0x232c});var client9002=jayson['client'][_0x998f('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x1a8be6,_0x477b10,_0x553597,_0x1c677e){return new BPromise(function(_0x256335,_0x28bb5a){var _0x28eac3=_0x1c677e||client;return _0x28eac3[_0x998f('0x22')](_0x1a8be6,_0x553597)[_0x998f('0x23')](function(_0x13081f){logger['info']('OpenchannelAccount,\x20%s,\x20%s',_0x477b10,'request\x20sent');logger['debug']('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0x477b10,_0x998f('0x24'),JSON[_0x998f('0x25')](_0x13081f));if(_0x13081f[_0x998f('0x26')]){if(_0x13081f[_0x998f('0x26')]['code']===0x1f4){logger[_0x998f('0x26')](_0x998f('0x27'),_0x477b10,_0x13081f[_0x998f('0x26')][_0x998f('0x28')]);return _0x28bb5a(_0x13081f['error'][_0x998f('0x28')]);}logger[_0x998f('0x26')](_0x998f('0x27'),_0x477b10,_0x13081f[_0x998f('0x26')][_0x998f('0x28')]);return _0x256335(_0x13081f['error'][_0x998f('0x28')]);}else{logger['info'](_0x998f('0x27'),_0x477b10,'request\x20sent');_0x256335(_0x13081f['result'][_0x998f('0x28')]);}})[_0x998f('0x29')](function(_0x2699ce){logger[_0x998f('0x26')]('OpenchannelAccount,\x20%s,\x20%s',_0x477b10,_0x2699ce);_0x28bb5a(_0x2699ce);});});}function respondWithStatusCode(_0x2fd371,_0x10cdc2){_0x10cdc2=_0x10cdc2||0xcc;return function(_0x61fe57){if(_0x61fe57){return _0x2fd371['sendStatus'](_0x10cdc2);}return _0x2fd371[_0x998f('0x2a')](_0x10cdc2)['end']();};}function respondWithResult(_0x4a43a7,_0x592c0b){_0x592c0b=_0x592c0b||0xc8;return function(_0x52c539){if(_0x52c539){return _0x4a43a7[_0x998f('0x2a')](_0x592c0b)[_0x998f('0x2b')](_0x52c539);}};}function respondWithFilteredResult(_0x176774,_0x56cb29){return function(_0x182259){if(_0x182259){var _0x78e261=_0x182259[_0x998f('0x2c')],_0x1ac57e=_0x56cb29[_0x998f('0x2d')],_0x47fd98=_0x56cb29['offset']+_0x56cb29[_0x998f('0x2e')],_0x4a141a;if(_0x47fd98>=_0x78e261){_0x47fd98=_0x78e261;_0x4a141a=0xc8;}else{_0x4a141a=0xce;}_0x176774[_0x998f('0x2a')](_0x4a141a);return _0x176774[_0x998f('0x2f')](_0x998f('0x30'),_0x1ac57e+'-'+_0x47fd98+'/'+_0x78e261)[_0x998f('0x2b')](_0x182259);}return null;};}function patchUpdates(_0x14d99b){return function(_0x1c7755){try{jsonpatch[_0x998f('0x31')](_0x1c7755,_0x14d99b,!![]);}catch(_0x2b8ae0){return BPromise[_0x998f('0x32')](_0x2b8ae0);}return _0x1c7755[_0x998f('0x33')]();};}function saveUpdates(_0x43cb26,_0x464cfb){return function(_0x3ad1ad){if(_0x3ad1ad){return _0x3ad1ad[_0x998f('0x34')](_0x43cb26)['then'](function(_0xcb7823){return _0xcb7823;});}return null;};}function removeEntity(_0x3c59f3,_0x1835bc){return function(_0x4042e7){if(_0x4042e7){return _0x4042e7[_0x998f('0x35')]()[_0x998f('0x23')](function(){var _0x13a4eb=_0x4042e7['get']({'plain':!![]});var _0x4328e7=_0x998f('0x36');return db[_0x998f('0x37')][_0x998f('0x35')]({'where':{'type':_0x4328e7,'resourceId':_0x13a4eb['id']}})[_0x998f('0x23')](function(){return _0x4042e7;});})['then'](function(){_0x3c59f3[_0x998f('0x2a')](0xcc)[_0x998f('0x38')]();});}};}function handleEntityNotFound(_0xcae573,_0x4bf7d5){return function(_0x3b556c){if(!_0x3b556c){_0xcae573[_0x998f('0x39')](0x194);}return _0x3b556c;};}function handleError(_0x40f08b,_0x2aa431){_0x2aa431=_0x2aa431||0x1f4;return function(_0x4c930b){logger['error'](_0x4c930b['stack']);if(_0x4c930b[_0x998f('0x3a')]){delete _0x4c930b[_0x998f('0x3a')];}_0x40f08b[_0x998f('0x2a')](_0x2aa431)['send'](_0x4c930b);};}exports[_0x998f('0x3b')]=function(_0x385f5c,_0x5004de){var _0x58a6f4={'include':[{'model':db[_0x998f('0x3c')],'as':_0x998f('0x3d')}]},_0x146641={},_0x309ff4={'count':0x0,'rows':[]};var _0x34cdc9=_[_0x998f('0x3e')](db[_0x998f('0x3f')]['rawAttributes'],function(_0x3fb8ec){return{'name':_0x3fb8ec[_0x998f('0x40')],'type':_0x3fb8ec[_0x998f('0x41')]['key']};});_0x146641[_0x998f('0x42')]=_[_0x998f('0x3e')](_0x34cdc9,_0x998f('0x3a'));_0x146641[_0x998f('0x43')]=_['keys'](_0x385f5c[_0x998f('0x43')]);_0x146641[_0x998f('0x44')]=_['intersection'](_0x146641['model'],_0x146641[_0x998f('0x43')]);_0x58a6f4[_0x998f('0x45')]=_['intersection'](_0x146641[_0x998f('0x42')],qs[_0x998f('0x46')](_0x385f5c[_0x998f('0x43')]['fields']));_0x58a6f4[_0x998f('0x45')]=_0x58a6f4[_0x998f('0x45')]['length']?_0x58a6f4[_0x998f('0x45')]:_0x146641['model'];if(!_0x385f5c[_0x998f('0x43')][_0x998f('0x47')](_0x998f('0x48'))){_0x58a6f4['limit']=qs['limit'](_0x385f5c[_0x998f('0x43')][_0x998f('0x2e')]);_0x58a6f4[_0x998f('0x2d')]=qs[_0x998f('0x2d')](_0x385f5c[_0x998f('0x43')][_0x998f('0x2d')]);}_0x58a6f4[_0x998f('0x49')]=qs['sort'](_0x385f5c[_0x998f('0x43')]['sort']);_0x58a6f4[_0x998f('0x4a')]=qs[_0x998f('0x44')](_[_0x998f('0x4b')](_0x385f5c[_0x998f('0x43')],_0x146641[_0x998f('0x44')]),_0x34cdc9);if(_0x385f5c[_0x998f('0x43')][_0x998f('0x4c')]){_0x58a6f4['where']=_['merge'](_0x58a6f4['where'],{'$or':_[_0x998f('0x3e')](_0x34cdc9,function(_0x48c4c7){if(_0x48c4c7[_0x998f('0x41')]!==_0x998f('0x4d')){var _0x4376c7={};_0x4376c7[_0x48c4c7[_0x998f('0x3a')]]={'$like':'%'+_0x385f5c[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x4376c7;}})});}_0x58a6f4=_[_0x998f('0x4e')]({},_0x58a6f4,_0x385f5c[_0x998f('0x4f')]);var _0x1326df={'where':_0x58a6f4[_0x998f('0x4a')]};return db[_0x998f('0x3f')][_0x998f('0x2c')](_0x1326df)[_0x998f('0x23')](function(_0x58952d){_0x309ff4[_0x998f('0x2c')]=_0x58952d;if(_0x385f5c['query'][_0x998f('0x50')]){_0x58a6f4[_0x998f('0x51')]=[{'all':!![]}];}return db[_0x998f('0x3f')][_0x998f('0x52')](_0x58a6f4);})['then'](function(_0x529815){_0x309ff4['rows']=_0x529815;return _0x309ff4;})[_0x998f('0x23')](respondWithFilteredResult(_0x5004de,_0x58a6f4))['catch'](handleError(_0x5004de,null));};exports[_0x998f('0x53')]=function(_0x55b16d,_0x2dadac){var _0x2ba0e6={'raw':![],'where':{'id':_0x55b16d[_0x998f('0x54')]['id']},'include':[{'model':db[_0x998f('0x3c')],'as':'mandatoryDispositionPause'}]},_0x204c19={};_0x204c19['model']=_[_0x998f('0x55')](db['OpenchannelAccount']['rawAttributes']);_0x204c19['query']=_[_0x998f('0x55')](_0x55b16d['query']);_0x204c19['filters']=_[_0x998f('0x56')](_0x204c19['model'],_0x204c19['query']);_0x2ba0e6[_0x998f('0x45')]=_[_0x998f('0x56')](_0x204c19[_0x998f('0x42')],qs[_0x998f('0x46')](_0x55b16d['query'][_0x998f('0x46')]));_0x2ba0e6[_0x998f('0x45')]=_0x2ba0e6[_0x998f('0x45')][_0x998f('0x57')]?_0x2ba0e6[_0x998f('0x45')]:_0x204c19['model'];if(_0x55b16d[_0x998f('0x43')][_0x998f('0x50')]){_0x2ba0e6[_0x998f('0x51')]=[{'all':!![]}];}_0x2ba0e6=_[_0x998f('0x4e')]({},_0x2ba0e6,_0x55b16d[_0x998f('0x4f')]);return db[_0x998f('0x3f')]['find'](_0x2ba0e6)[_0x998f('0x23')](handleEntityNotFound(_0x2dadac,null))[_0x998f('0x23')](respondWithResult(_0x2dadac,null))[_0x998f('0x29')](handleError(_0x2dadac,null));};exports[_0x998f('0x58')]=function(_0x424377,_0x4bee9e){return db[_0x998f('0x3f')][_0x998f('0x58')](_0x424377[_0x998f('0x59')],{})[_0x998f('0x23')](function(_0x1b063d){var _0x11221b=_0x424377[_0x998f('0x5a')][_0x998f('0x5b')]({'plain':!![]});if(!_0x11221b)throw new Error(_0x998f('0x5c'));if(_0x11221b[_0x998f('0x5d')]===_0x998f('0x5a')){var _0x3c688e=_0x1b063d[_0x998f('0x5b')]({'plain':!![]});var _0x51ac52='OpenchannelAccounts';return db[_0x998f('0x5e')]['find']({'where':{'name':_0x51ac52,'userProfileId':_0x11221b[_0x998f('0x5f')]},'raw':!![]})['then'](function(_0x1b51cb){if(_0x1b51cb&&_0x1b51cb[_0x998f('0x60')]===0x0){return db[_0x998f('0x37')]['create']({'name':_0x3c688e[_0x998f('0x3a')],'resourceId':_0x3c688e['id'],'type':_0x1b51cb['name'],'sectionId':_0x1b51cb['id']},{})[_0x998f('0x23')](function(){return _0x1b063d;});}else{return _0x1b063d;}})[_0x998f('0x29')](function(_0x209bc2){logger[_0x998f('0x26')](_0x998f('0x61'),_0x209bc2);throw _0x209bc2;});}return _0x1b063d;})[_0x998f('0x23')](respondWithResult(_0x4bee9e,0xc9))[_0x998f('0x29')](handleError(_0x4bee9e,null));};exports[_0x998f('0x34')]=function(_0x3bc4aa,_0x2c0b3b){if(_0x3bc4aa[_0x998f('0x59')]['id']){delete _0x3bc4aa[_0x998f('0x59')]['id'];}return db['OpenchannelAccount']['find']({'where':{'id':_0x3bc4aa[_0x998f('0x54')]['id']},'include':[{'model':db[_0x998f('0x3c')],'as':'mandatoryDispositionPause'}]})[_0x998f('0x23')](handleEntityNotFound(_0x2c0b3b,null))[_0x998f('0x23')](saveUpdates(_0x3bc4aa['body'],null))[_0x998f('0x23')](respondWithResult(_0x2c0b3b,null))[_0x998f('0x29')](handleError(_0x2c0b3b,null));};exports[_0x998f('0x35')]=function(_0x4890fb,_0x3f70a7){return db[_0x998f('0x3f')]['find']({'where':{'id':_0x4890fb[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x3f70a7,null))[_0x998f('0x23')](removeEntity(_0x3f70a7,null))[_0x998f('0x29')](handleError(_0x3f70a7,null));};exports[_0x998f('0x62')]=function(_0x2d70f3,_0x49e298){return db[_0x998f('0x3f')][_0x998f('0x62')]()[_0x998f('0x23')](respondWithResult(_0x49e298,null))[_0x998f('0x29')](handleError(_0x49e298,null));};exports['addDisposition']=function(_0x1c07df,_0x4d8f7a,_0x190927){if(_0x1c07df['body']['id']){delete _0x1c07df[_0x998f('0x59')]['id'];}return db[_0x998f('0x3f')][_0x998f('0x63')]({'where':{'id':_0x1c07df[_0x998f('0x54')]['id']}})['then'](handleEntityNotFound(_0x4d8f7a,null))[_0x998f('0x23')](function(_0x441eb9){if(_0x441eb9){_0x1c07df['body']['OpenchannelAccountId']=_0x441eb9['id'];return db[_0x998f('0x64')][_0x998f('0x58')](_0x1c07df[_0x998f('0x59')]);}})[_0x998f('0x23')](respondWithResult(_0x4d8f7a,null))[_0x998f('0x29')](handleError(_0x4d8f7a,null));};exports[_0x998f('0x65')]=function(_0x20de63,_0x21a2e8,_0x289986){var _0x91d6f8={'raw':![],'where':{}};var _0x6f2b91={};var _0x3ad445={'count':0x0,'rows':[]};return db[_0x998f('0x3f')][_0x998f('0x66')]({'where':{'id':_0x20de63[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x21a2e8,null))[_0x998f('0x23')](function(_0x14f241){if(_0x14f241){_0x6f2b91[_0x998f('0x42')]=_[_0x998f('0x55')](db[_0x998f('0x64')][_0x998f('0x67')]);_0x6f2b91['query']=_[_0x998f('0x55')](_0x20de63[_0x998f('0x43')]);_0x6f2b91[_0x998f('0x44')]=_[_0x998f('0x56')](_0x6f2b91['model'],_0x6f2b91['query']);_0x91d6f8[_0x998f('0x45')]=_[_0x998f('0x56')](_0x6f2b91[_0x998f('0x42')],qs['fields'](_0x20de63['query'][_0x998f('0x46')]));_0x91d6f8[_0x998f('0x45')]=_0x91d6f8[_0x998f('0x45')][_0x998f('0x57')]?_0x91d6f8['attributes']:_0x6f2b91[_0x998f('0x42')];if(!_0x20de63[_0x998f('0x43')][_0x998f('0x47')]('nolimit')){_0x91d6f8[_0x998f('0x2e')]=qs['limit'](_0x20de63['query']['limit']);_0x91d6f8[_0x998f('0x2d')]=qs['offset'](_0x20de63[_0x998f('0x43')][_0x998f('0x2d')]);}_0x91d6f8[_0x998f('0x49')]=qs[_0x998f('0x68')](_0x20de63['query']['sort']);_0x91d6f8[_0x998f('0x4a')]=qs[_0x998f('0x44')](_[_0x998f('0x4b')](_0x20de63[_0x998f('0x43')],_0x6f2b91[_0x998f('0x44')]));_0x91d6f8['where'][_0x998f('0x69')]=_0x14f241['id'];if(_0x20de63[_0x998f('0x43')][_0x998f('0x4c')]){_0x91d6f8[_0x998f('0x4a')]=_[_0x998f('0x4e')](_0x91d6f8[_0x998f('0x4a')],{'$or':_[_0x998f('0x3e')](_0x91d6f8['attributes'],function(_0x29dd1d){var _0x199a50={};_0x199a50[_0x29dd1d]={'$like':'%'+_0x20de63[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x199a50;})});}_0x91d6f8=_[_0x998f('0x4e')]({},_0x91d6f8,_0x20de63['options']);return db[_0x998f('0x64')]['count']({'where':_0x91d6f8[_0x998f('0x4a')]})[_0x998f('0x23')](function(_0x5b2d81){_0x3ad445['count']=_0x5b2d81;if(_0x20de63[_0x998f('0x43')][_0x998f('0x50')]){_0x91d6f8[_0x998f('0x51')]=[{'all':!![]}];}return db['Disposition']['findAll'](_0x91d6f8);})[_0x998f('0x23')](function(_0x762167){_0x3ad445[_0x998f('0x6a')]=_0x762167;return _0x3ad445;});}})[_0x998f('0x23')](respondWithFilteredResult(_0x21a2e8,_0x91d6f8))[_0x998f('0x29')](handleError(_0x21a2e8,null));};exports['removeDispositions']=function(_0x34d7ae,_0x27fd04,_0x1f66bb){return db['OpenchannelAccount']['find']({'where':{'id':_0x34d7ae['params']['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x27fd04,null))[_0x998f('0x23')](function(_0x2f3d6c){if(_0x2f3d6c){return _0x2f3d6c[_0x998f('0x6b')](_0x34d7ae[_0x998f('0x43')][_0x998f('0x6c')]);}})[_0x998f('0x23')](respondWithStatusCode(_0x27fd04,null))[_0x998f('0x29')](handleError(_0x27fd04,null));};exports[_0x998f('0x6d')]=function(_0x25ff5f,_0xf2c72b,_0x1d070b){if(_0x25ff5f['body']['id']){delete _0x25ff5f[_0x998f('0x59')]['id'];}return db['OpenchannelAccount'][_0x998f('0x63')]({'where':{'id':_0x25ff5f['params']['id']}})['then'](handleEntityNotFound(_0xf2c72b,null))[_0x998f('0x23')](function(_0x4f0ab5){if(_0x4f0ab5){_0x25ff5f[_0x998f('0x59')][_0x998f('0x69')]=_0x4f0ab5['id'];return db[_0x998f('0x6e')][_0x998f('0x58')](_0x25ff5f[_0x998f('0x59')]);}})[_0x998f('0x23')](respondWithResult(_0xf2c72b,null))['catch'](handleError(_0xf2c72b,null));};exports[_0x998f('0x6f')]=function(_0x5d6d85,_0x78db71,_0x5cdf18){var _0x3995a9={'raw':![],'where':{}};var _0x2c6ff8={};var _0x1e719e={'count':0x0,'rows':[]};return db[_0x998f('0x3f')][_0x998f('0x66')]({'where':{'id':_0x5d6d85['params']['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x78db71,null))[_0x998f('0x23')](function(_0x515d5d){if(_0x515d5d){_0x2c6ff8['model']=_['keys'](db['CannedAnswer'][_0x998f('0x67')]);_0x2c6ff8['query']=_[_0x998f('0x55')](_0x5d6d85[_0x998f('0x43')]);_0x2c6ff8['filters']=_['intersection'](_0x2c6ff8[_0x998f('0x42')],_0x2c6ff8[_0x998f('0x43')]);_0x3995a9[_0x998f('0x45')]=_['intersection'](_0x2c6ff8[_0x998f('0x42')],qs[_0x998f('0x46')](_0x5d6d85[_0x998f('0x43')][_0x998f('0x46')]));_0x3995a9['attributes']=_0x3995a9['attributes'][_0x998f('0x57')]?_0x3995a9[_0x998f('0x45')]:_0x2c6ff8[_0x998f('0x42')];if(!_0x5d6d85[_0x998f('0x43')]['hasOwnProperty']('nolimit')){_0x3995a9[_0x998f('0x2e')]=qs[_0x998f('0x2e')](_0x5d6d85[_0x998f('0x43')]['limit']);_0x3995a9[_0x998f('0x2d')]=qs['offset'](_0x5d6d85[_0x998f('0x43')][_0x998f('0x2d')]);}_0x3995a9[_0x998f('0x49')]=qs[_0x998f('0x68')](_0x5d6d85['query']['sort']);_0x3995a9[_0x998f('0x4a')]=qs['filters'](_[_0x998f('0x4b')](_0x5d6d85['query'],_0x2c6ff8['filters']));_0x3995a9[_0x998f('0x4a')][_0x998f('0x69')]=_0x515d5d['id'];if(_0x5d6d85['query'][_0x998f('0x4c')]){_0x3995a9[_0x998f('0x4a')]=_[_0x998f('0x4e')](_0x3995a9[_0x998f('0x4a')],{'$or':_[_0x998f('0x3e')](_0x3995a9[_0x998f('0x45')],function(_0x533a95){var _0x53cb19={};_0x53cb19[_0x533a95]={'$like':'%'+_0x5d6d85[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x53cb19;})});}_0x3995a9=_[_0x998f('0x4e')]({},_0x3995a9,_0x5d6d85[_0x998f('0x4f')]);return db['CannedAnswer'][_0x998f('0x2c')]({'where':_0x3995a9[_0x998f('0x4a')]})[_0x998f('0x23')](function(_0x21eb4b){_0x1e719e[_0x998f('0x2c')]=_0x21eb4b;if(_0x5d6d85[_0x998f('0x43')][_0x998f('0x50')]){_0x3995a9[_0x998f('0x51')]=[{'all':!![]}];}return db['CannedAnswer']['findAll'](_0x3995a9);})[_0x998f('0x23')](function(_0x2da523){_0x1e719e['rows']=_0x2da523;return _0x1e719e;});}})[_0x998f('0x23')](respondWithFilteredResult(_0x78db71,_0x3995a9))[_0x998f('0x29')](handleError(_0x78db71,null));};exports[_0x998f('0x70')]=function(_0x2979ae,_0x200b32,_0x893fde){return db[_0x998f('0x3f')][_0x998f('0x63')]({'where':{'id':_0x2979ae[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x200b32,null))[_0x998f('0x23')](function(_0x229448){if(_0x229448){return _0x229448[_0x998f('0x70')](_0x2979ae[_0x998f('0x43')][_0x998f('0x6c')]);}})[_0x998f('0x23')](respondWithStatusCode(_0x200b32,null))[_0x998f('0x29')](handleError(_0x200b32,null));};exports[_0x998f('0x71')]=function(_0x10fa96,_0x4ddf4b,_0x1b2e04){var _0x2f0e5f={'body':_0x10fa96['body'],'channel':_0x998f('0x72')};var _0x2023ca=[];var _0x185aa3=[];var _0x760dd2={};var _0x311051=![];return db['CmContact'][_0x998f('0x62')]()[_0x998f('0x23')](function(_0x1a53a1){if(!_0x1a53a1){throw new db[(_0x998f('0x73'))][(_0x998f('0x74'))](_0x998f('0x75'));}_0x2023ca=_[_0x998f('0x76')](_[_0x998f('0x55')](_0x1a53a1),[_0x998f('0x77'),_0x998f('0x78')]);_0x185aa3=_[_0x998f('0x76')](_[_0x998f('0x55')](_0x1a53a1),[_0x998f('0x77'),_0x998f('0x78'),_0x998f('0x79'),'ListId']);if(_0x10fa96[_0x998f('0x59')]['id']){delete _0x10fa96[_0x998f('0x59')]['id'];}if(_[_0x998f('0x7a')](_0x10fa96['body'][_0x998f('0x7b')])){throw new db[(_0x998f('0x73'))]['ValidationError'](_0x998f('0x7c'));}if(_['isNil'](_0x10fa96[_0x998f('0x59')][_0x998f('0x59')])||_0x10fa96['body'][_0x998f('0x59')]===''){throw new db[(_0x998f('0x73'))][(_0x998f('0x74'))](_0x998f('0x7d'));}if(_[_0x998f('0x7a')](_0x10fa96[_0x998f('0x59')]['mapKey'])){throw new db[(_0x998f('0x73'))][(_0x998f('0x74'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x185aa3);}if(!_[_0x998f('0x7e')](_0x185aa3,_0x10fa96[_0x998f('0x59')][_0x998f('0x7f')])){throw new db[(_0x998f('0x73'))][(_0x998f('0x74'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x185aa3);}_0x760dd2[_0x10fa96[_0x998f('0x59')][_0x998f('0x7f')]]=_0x10fa96[_0x998f('0x59')]['from'];})[_0x998f('0x23')](function(){return db[_0x998f('0x3f')]['find']({'where':{'id':_0x10fa96[_0x998f('0x54')]['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db[_0x998f('0x80')],'as':_0x998f('0x81'),'where':_0x760dd2,'limit':0x1,'order':[['updatedAt',_0x998f('0x82')]]}]},{'model':db['OpenchannelApplication'],'as':_0x998f('0x83')}]});})['then'](handleEntityNotFound(_0x4ddf4b,null))[_0x998f('0x23')](function(_0x23e8bf){if(_0x23e8bf&&_0x23e8bf[_0x998f('0x84')]){_0x2f0e5f[_0x998f('0x85')]=_0x23e8bf;_0x2f0e5f[_0x998f('0x86')]=_0x23e8bf[_0x998f('0x83')];_0x2f0e5f[_0x998f('0x87')]=_0x23e8bf[_0x998f('0x84')];_0x2f0e5f[_0x998f('0x86')]=_[_0x998f('0x88')](_0x2f0e5f[_0x998f('0x86')],['priority'],['asc']);if(_0x2f0e5f[_0x998f('0x85')][_0x998f('0x83')]){delete _0x2f0e5f['account'][_0x998f('0x83')];}if(_0x2f0e5f[_0x998f('0x85')][_0x998f('0x84')]&&_0x2f0e5f[_0x998f('0x85')][_0x998f('0x84')][_0x998f('0x81')][_0x998f('0x57')]){return _0x2f0e5f['account'][_0x998f('0x84')]['Contacts'][0x0];}var _0x418494=_['defaults'](_0x10fa96[_0x998f('0x59')],{'firstName':_0x10fa96[_0x998f('0x59')][_0x998f('0x7b')],'ListId':_0x23e8bf[_0x998f('0x89')]});_0x418494[_0x10fa96['body'][_0x998f('0x7f')]]=_0x10fa96['body'][_0x998f('0x7b')];return db[_0x998f('0x80')][_0x998f('0x58')](_0x418494,{'fields':_0x2023ca,'raw':!![]});}})[_0x998f('0x23')](handleEntityNotFound(_0x4ddf4b,null))[_0x998f('0x23')](function(_0x730ee2){_0x2f0e5f[_0x998f('0x8a')]=_0x730ee2;if(_0x730ee2){var _0x3147f8={'ContactId':_0x730ee2['id'],'OpenchannelAccountId':_0x10fa96[_0x998f('0x54')]['id'],'from':(_0x730ee2[_0x998f('0x8b')]||'')+'\x20'+(_0x730ee2[_0x998f('0x8c')]||'')};var _0x23ea47={'OpenchannelAccountId':_0x10fa96[_0x998f('0x54')]['id'],'closed':![]};if(_0x10fa96[_0x998f('0x59')]['threadId']){_0x23ea47['threadId']=_0x10fa96[_0x998f('0x59')][_0x998f('0x8d')];return db[_0x998f('0x8e')][_0x998f('0x63')]({'where':_0x23ea47})[_0x998f('0x23')](function(_0x1ad479){if(_0x1ad479){return[_0x1ad479,![]];}_0x3147f8[_0x998f('0x8d')]=_0x10fa96['body']['threadId'];_0x3147f8[_0x998f('0x8f')]=_0x10fa96[_0x998f('0x59')][_0x998f('0x8f')];return db[_0x998f('0x8e')][_0x998f('0x58')](_0x3147f8)[_0x998f('0x23')](function(_0x511031){return[_0x511031,!![]];});});}else{_0x23ea47[_0x998f('0x8d')]=null;}_0x23ea47[_0x998f('0x90')]=_0x730ee2['id'];return db[_0x998f('0x8e')]['find']({'where':_0x23ea47})['then'](function(_0x1ebf31){if(_0x1ebf31){return[_0x1ebf31,![]];}return db['OpenchannelInteraction'][_0x998f('0x58')](_0x3147f8)[_0x998f('0x23')](function(_0x5f92d6){return[_0x5f92d6,!![]];});});}})[_0x998f('0x91')](function(_0x3267b5,_0x43b3f0){if(_0x3267b5){_0x311051=_0x43b3f0;if(!_0x43b3f0){var _0x2dfd1f={'from':(_0x2f0e5f[_0x998f('0x8a')]['firstName']||'')+'\x20'+(_0x2f0e5f[_0x998f('0x8a')]['lastName']||'')};if(_0x10fa96[_0x998f('0x59')][_0x998f('0x8d')]&&_0x10fa96[_0x998f('0x59')][_0x998f('0x92')]&&_0x10fa96[_0x998f('0x59')]['threadId']!=_0x10fa96[_0x998f('0x59')][_0x998f('0x92')]){_0x2dfd1f['threadId']=_0x10fa96[_0x998f('0x59')][_0x998f('0x92')];}return _0x3267b5['update'](_0x2dfd1f);}else{return _0x3267b5;}}})[_0x998f('0x23')](function(_0xee789c){_0x2f0e5f[_0x998f('0x93')]=_0xee789c[_0x998f('0x5b')]({'plain':!![]});_0x2f0e5f[_0x998f('0x93')][_0x998f('0x94')]=_0x311051;if(_0x2f0e5f['interaction'][_0x998f('0x94')]){if(_0x2f0e5f[_0x998f('0x85')][_0x998f('0x95')]){_0x2f0e5f['applications'][_0x998f('0x96')]({'id':0x0,'priority':_0x2f0e5f[_0x998f('0x86')]['length']+0x1,'app':'close','appdata':_0x998f('0x97'),'interval':'*,*,*,*'});}}return db[_0x998f('0x98')][_0x998f('0x58')]({'body':_0x10fa96[_0x998f('0x59')][_0x998f('0x59')],'OpenchannelAccountId':_0x10fa96[_0x998f('0x54')]['id'],'OpenchannelInteractionId':_0xee789c['id'],'direction':'in','ContactId':_0x2f0e5f[_0x998f('0x8a')]['id'],'AttachmentId':_0x10fa96['body'][_0x998f('0x99')]});})[_0x998f('0x23')](function(_0x139da8){_0x2f0e5f[_0x998f('0x28')]=_0x139da8;if(_0x2f0e5f['interaction'][_0x998f('0x9a')]){return db[_0x998f('0x9b')][_0x998f('0x63')]({'attributes':['id','name'],'where':{'id':_0x2f0e5f[_0x998f('0x93')]['UserId']}})[_0x998f('0x23')](function(_0x53ef82){if(_0x53ef82){_0x2f0e5f[_0x998f('0x86')][_0x998f('0x9c')]({'id':0x0,'priority':0x0,'app':_0x998f('0x9d'),'appdata':_0x53ef82[_0x998f('0x3a')]+','+(_0x2f0e5f[_0x998f('0x85')][_0x998f('0x9e')]||0xa),'interval':_0x998f('0x9f')});_0x2f0e5f[_0x998f('0xa0')]=![];}return respondWithRpcPromise(_0x998f('0xa1'),_0x998f('0xa2'),_0x2f0e5f);});}return respondWithRpcPromise(_0x998f('0xa1'),_0x998f('0xa2'),_0x2f0e5f);})[_0x998f('0x23')](function(_0x22b0e9){respondWithRpcPromise('EventManager',_0x998f('0xa3'),{'event':'notify','message':_0x22b0e9},client9002);return _0x22b0e9;})[_0x998f('0x23')](respondWithResult(_0x4ddf4b,null))['catch'](handleError(_0x4ddf4b,null));};exports[_0x998f('0xa4')]=function(_0x357246,_0x5016f7,_0x67475b){return db[_0x998f('0x3f')][_0x998f('0x66')]({'where':{'id':_0x357246['params']['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x5016f7,null))['then'](function(_0x5abff1){if(_0x5abff1){return db[_0x998f('0xa5')][_0x998f('0xa6')](function(_0xc39d2d){return db[_0x998f('0xa7')][_0x998f('0x35')]({'where':{'OpenchannelAccountId':_0x357246[_0x998f('0x54')]['id']},'transaction':_0xc39d2d})[_0x998f('0x23')](function(_0x431578){var _0x55c899=_[_0x998f('0x3e')](_0x357246[_0x998f('0x59')],function(_0x5859c2){_0x5859c2[_0x998f('0x69')]=_0x357246[_0x998f('0x54')]['id'];return _0x5859c2;});return db[_0x998f('0xa7')][_0x998f('0xa8')](_0x55c899,{'transaction':_0xc39d2d});});})[_0x998f('0x23')](function(){return db[_0x998f('0xa7')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0x357246[_0x998f('0x54')]['id']},'order':_0x998f('0xa9')});});}})[_0x998f('0x23')](respondWithResult(_0x5016f7,null))[_0x998f('0x29')](handleError(_0x5016f7,null));};exports[_0x998f('0xaa')]=function(_0xcea3e9,_0x5e9615,_0x116378){var _0x3ba660={};var _0x2e9c66={};var _0x484805;var _0x1f9d6f;return db[_0x998f('0x3f')][_0x998f('0x66')]({'where':{'id':_0xcea3e9['params']['id']}})['then'](handleEntityNotFound(_0x5e9615,null))[_0x998f('0x23')](function(_0x4434d4){if(_0x4434d4){_0x484805=_0x4434d4;_0x2e9c66['model']=_[_0x998f('0x55')](db['OpenchannelApplication'][_0x998f('0x67')]);_0x2e9c66[_0x998f('0x43')]=_['keys'](_0xcea3e9[_0x998f('0x43')]);_0x2e9c66[_0x998f('0x44')]=_[_0x998f('0x56')](_0x2e9c66['model'],_0x2e9c66[_0x998f('0x43')]);_0x3ba660[_0x998f('0x45')]=_[_0x998f('0x56')](_0x2e9c66[_0x998f('0x42')],qs[_0x998f('0x46')](_0xcea3e9[_0x998f('0x43')]['fields']));_0x3ba660[_0x998f('0x45')]=_0x3ba660[_0x998f('0x45')][_0x998f('0x57')]?_0x3ba660[_0x998f('0x45')]:_0x2e9c66[_0x998f('0x42')];_0x3ba660[_0x998f('0x49')]=qs[_0x998f('0x68')](_0xcea3e9[_0x998f('0x43')]['sort']);_0x3ba660[_0x998f('0x4a')]=qs['filters'](_[_0x998f('0x4b')](_0xcea3e9[_0x998f('0x43')],_0x2e9c66['filters']));if(_0xcea3e9['query'][_0x998f('0x4c')]){_0x3ba660[_0x998f('0x4a')]=_[_0x998f('0x4e')](_0x3ba660[_0x998f('0x4a')],{'$or':_[_0x998f('0x3e')](_0x3ba660[_0x998f('0x45')],function(_0x194fa8){var _0x34e410={};_0x34e410[_0x194fa8]={'$like':'%'+_0xcea3e9[_0x998f('0x43')]['filter']+'%'};return _0x34e410;})});}_0x3ba660=_[_0x998f('0x4e')]({},_0x3ba660,_0xcea3e9['options']);return _0x484805[_0x998f('0xaa')](_0x3ba660);}})[_0x998f('0x23')](function(_0x427f77){if(_0x427f77){_0x1f9d6f=_0x427f77['length'];if(!_0xcea3e9[_0x998f('0x43')][_0x998f('0x47')](_0x998f('0x48'))){_0x3ba660[_0x998f('0x2e')]=qs['limit'](_0xcea3e9['query'][_0x998f('0x2e')]);_0x3ba660[_0x998f('0x2d')]=qs[_0x998f('0x2d')](_0xcea3e9[_0x998f('0x43')][_0x998f('0x2d')]);}return _0x484805['getApplications'](_0x3ba660);}})[_0x998f('0x23')](function(_0x339f8c){if(_0x339f8c){return _0x339f8c?{'count':_0x1f9d6f,'rows':_0x339f8c}:null;}})[_0x998f('0x23')](respondWithResult(_0x5e9615,null))['catch'](handleError(_0x5e9615,null));};exports['getInteractions']=function(_0x4ee278,_0x1259be,_0x7c5798){var _0x25cd1a={'raw':![],'where':{}};var _0x470df5={};var _0x4791e8={'count':0x0,'rows':[]};return db['OpenchannelAccount']['findOne']({'where':{'id':_0x4ee278[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x1259be,null))[_0x998f('0x23')](function(_0x110ccf){if(_0x110ccf){_0x470df5['model']=_[_0x998f('0x55')](db['OpenchannelInteraction'][_0x998f('0x67')]);_0x470df5[_0x998f('0x43')]=_[_0x998f('0x55')](_0x4ee278[_0x998f('0x43')]);_0x470df5[_0x998f('0x44')]=_[_0x998f('0x56')](_0x470df5['model'],_0x470df5[_0x998f('0x43')]);_0x25cd1a['attributes']=_[_0x998f('0x56')](_0x470df5['model'],qs[_0x998f('0x46')](_0x4ee278[_0x998f('0x43')][_0x998f('0x46')]));_0x25cd1a['attributes']=_0x25cd1a[_0x998f('0x45')][_0x998f('0x57')]?_0x25cd1a[_0x998f('0x45')]:_0x470df5['model'];if(!_0x4ee278['query']['hasOwnProperty'](_0x998f('0x48'))){_0x25cd1a[_0x998f('0x2e')]=qs[_0x998f('0x2e')](_0x4ee278[_0x998f('0x43')]['limit']);_0x25cd1a[_0x998f('0x2d')]=qs['offset'](_0x4ee278['query']['offset']);}_0x25cd1a[_0x998f('0x49')]=qs[_0x998f('0x68')](_0x4ee278[_0x998f('0x43')][_0x998f('0x68')]);_0x25cd1a[_0x998f('0x4a')]=qs[_0x998f('0x44')](_[_0x998f('0x4b')](_0x4ee278[_0x998f('0x43')],_0x470df5[_0x998f('0x44')]));_0x25cd1a[_0x998f('0x4a')]['OpenchannelAccountId']=_0x110ccf['id'];if(_0x4ee278[_0x998f('0x43')][_0x998f('0x4c')]){_0x25cd1a[_0x998f('0x4a')]=_[_0x998f('0x4e')](_0x25cd1a['where'],{'$or':_[_0x998f('0x3e')](_0x25cd1a[_0x998f('0x45')],function(_0x51d3d0){var _0x16bff3={};_0x16bff3[_0x51d3d0]={'$like':'%'+_0x4ee278[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x16bff3;})});}_0x25cd1a=_[_0x998f('0x4e')]({},_0x25cd1a,_0x4ee278['options']);return db[_0x998f('0x8e')][_0x998f('0x2c')]({'where':_0x25cd1a[_0x998f('0x4a')]})[_0x998f('0x23')](function(_0x358778){_0x4791e8[_0x998f('0x2c')]=_0x358778;if(_0x4ee278[_0x998f('0x43')][_0x998f('0x50')]){_0x25cd1a[_0x998f('0x51')]=[{'model':db[_0x998f('0x80')],'as':_0x998f('0xab'),'required':![]},{'model':db[_0x998f('0x9b')],'as':_0x998f('0xac'),'attributes':[_0x998f('0x3a'),_0x998f('0xad'),'internal'],'required':![]},{'model':db[_0x998f('0xae')],'as':_0x998f('0xaf'),'attributes':['id',_0x998f('0x3a'),'color'],'where':_0x4ee278[_0x998f('0x43')]['tag']?{'id':_0x4ee278['query']['tag']}:undefined,'required':_0x4ee278[_0x998f('0x43')]['tag']?!![]:![]}];}return db[_0x998f('0x8e')][_0x998f('0x52')](_0x25cd1a);})[_0x998f('0x23')](function(_0x1de9c5){_0x4791e8[_0x998f('0x6a')]=_0x1de9c5;return _0x4791e8;});}})[_0x998f('0x23')](respondWithFilteredResult(_0x1259be,_0x25cd1a))[_0x998f('0x29')](handleError(_0x1259be,null));};exports[_0x998f('0xb0')]=function(_0x527e07,_0x5d5da2,_0x21470d){return db[_0x998f('0x3f')][_0x998f('0x63')]({'where':{'id':_0x527e07[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x5d5da2,null))[_0x998f('0x23')](function(_0x51ee3d){if(_0x51ee3d){return _0x51ee3d['addAgents'](_0x527e07[_0x998f('0x59')][_0x998f('0x6c')],_[_0x998f('0xb1')](_0x527e07[_0x998f('0x59')],[_0x998f('0x6c'),'id'])||{})[_0x998f('0x91')](function(_0x58549a){for(var _0x4f705d=0x0;_0x4f705d<_0x527e07[_0x998f('0x59')][_0x998f('0x6c')]['length'];_0x4f705d+=0x1){socket[_0x998f('0xb2')]('userOpenchannelAccount:save',{'UserId':_0x527e07[_0x998f('0x59')][_0x998f('0x6c')][_0x4f705d],'OpenchannelAccountId':_0x527e07[_0x998f('0x54')]['id']});}return _0x58549a;});}})[_0x998f('0x23')](respondWithResult(_0x5d5da2,null))[_0x998f('0x29')](handleError(_0x5d5da2,null));};exports['removeAgents']=function(_0xaf5b31,_0x150384,_0x33fb99){return db[_0x998f('0x3f')][_0x998f('0x63')]({'where':{'id':_0xaf5b31[_0x998f('0x54')]['id']}})['then'](handleEntityNotFound(_0x150384,null))[_0x998f('0x23')](function(_0x269792){if(_0x269792){return _0x269792[_0x998f('0xb3')](_0xaf5b31['query'][_0x998f('0x6c')])[_0x998f('0x23')](function(){if(_[_0x998f('0xb4')](_0xaf5b31[_0x998f('0x43')][_0x998f('0x6c')])){for(var _0x50fa73=0x0;_0x50fa73<_0xaf5b31[_0x998f('0x43')]['ids'][_0x998f('0x57')];_0x50fa73+=0x1){socket[_0x998f('0xb2')]('userOpenchannelAccount:remove',{'UserId':Number(_0xaf5b31[_0x998f('0x43')][_0x998f('0x6c')][_0x50fa73]),'OpenchannelAccountId':Number(_0xaf5b31['params']['id'])});}}else{socket[_0x998f('0xb2')](_0x998f('0xb5'),{'UserId':Number(_0xaf5b31[_0x998f('0x43')]['ids']),'OpenchannelAccountId':Number(_0xaf5b31[_0x998f('0x54')]['id'])});}});}})['then'](respondWithStatusCode(_0x150384,null))[_0x998f('0x29')](handleError(_0x150384,null));};exports[_0x998f('0xb6')]=function(_0x2e8626,_0xfbe6c9,_0x24c2ba){var _0x4a2340={};var _0x12d850={};var _0x831c54;var _0xf7cc33;return db['OpenchannelAccount'][_0x998f('0x66')]({'where':{'id':_0x2e8626['params']['id']}})['then'](handleEntityNotFound(_0xfbe6c9,null))['then'](function(_0x2967f0){if(_0x2967f0){_0x831c54=_0x2967f0;_0x12d850['model']=_[_0x998f('0x55')](db[_0x998f('0x9b')][_0x998f('0x67')]);_0x12d850[_0x998f('0x43')]=_['keys'](_0x2e8626[_0x998f('0x43')]);_0x12d850[_0x998f('0x44')]=_[_0x998f('0x56')](_0x12d850[_0x998f('0x42')],_0x12d850[_0x998f('0x43')]);_0x4a2340['attributes']=_[_0x998f('0x56')](_0x12d850[_0x998f('0x42')],qs['fields'](_0x2e8626[_0x998f('0x43')]['fields']));_0x4a2340[_0x998f('0x45')]=_0x4a2340[_0x998f('0x45')]['length']?_0x4a2340[_0x998f('0x45')]:_0x12d850['model'];_0x4a2340[_0x998f('0x49')]=qs[_0x998f('0x68')](_0x2e8626['query'][_0x998f('0x68')]);_0x4a2340[_0x998f('0x4a')]=qs[_0x998f('0x44')](_[_0x998f('0x4b')](_0x2e8626['query'],_0x12d850['filters']));if(_0x2e8626[_0x998f('0x43')][_0x998f('0x4c')]){_0x4a2340[_0x998f('0x4a')]=_['merge'](_0x4a2340[_0x998f('0x4a')],{'$or':_[_0x998f('0x3e')](_0x4a2340['attributes'],function(_0x15e2d5){var _0x3ddc7b={};_0x3ddc7b[_0x15e2d5]={'$like':'%'+_0x2e8626[_0x998f('0x43')][_0x998f('0x4c')]+'%'};return _0x3ddc7b;})});}_0x4a2340=_['merge']({},_0x4a2340,_0x2e8626[_0x998f('0x4f')]);return _0x831c54['getAgents'](_0x4a2340);}})[_0x998f('0x23')](function(_0x4c1ab0){if(_0x4c1ab0){_0xf7cc33=_0x4c1ab0[_0x998f('0x57')];if(!_0x2e8626[_0x998f('0x43')]['hasOwnProperty'](_0x998f('0x48'))){_0x4a2340[_0x998f('0x2e')]=qs[_0x998f('0x2e')](_0x2e8626[_0x998f('0x43')][_0x998f('0x2e')]);_0x4a2340[_0x998f('0x2d')]=qs[_0x998f('0x2d')](_0x2e8626[_0x998f('0x43')][_0x998f('0x2d')]);}return _0x831c54[_0x998f('0xb6')](_0x4a2340);}})[_0x998f('0x23')](function(_0x4cbfbb){if(_0x4cbfbb){return _0x4cbfbb?{'count':_0xf7cc33,'rows':_0x4cbfbb}:null;}})[_0x998f('0x23')](respondWithResult(_0xfbe6c9,null))[_0x998f('0x29')](handleError(_0xfbe6c9,null));};exports[_0x998f('0xb7')]=function(_0x450082,_0x2ce5d4,_0x3c505f){var _0x303062,_0x58ed8a,_0x44c74e;if(_[_0x998f('0x7a')](_0x450082[_0x998f('0x59')][_0x998f('0x59')])||_0x450082['body'][_0x998f('0x59')]===''){throw new db['Sequelize'][(_0x998f('0x74'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x450082[_0x998f('0x59')]['to'])){}_0x303062=_0x450082[_0x998f('0x59')]['to'];return db[_0x998f('0x3f')]['findOne']({'where':{'id':_0x450082[_0x998f('0x54')]['id']}})[_0x998f('0x23')](handleEntityNotFound(_0x2ce5d4,null))[_0x998f('0x23')](function(_0x399df6){if(_0x399df6){return db['OpenchannelAccount']['find']({'where':{'id':_0x399df6['id']},'include':[{'model':db[_0x998f('0xb8')],'as':_0x998f('0x84'),'include':[{'model':db[_0x998f('0x80')],'as':_0x998f('0x81'),'where':{[_0x399df6['mapKey']]:_0x303062},'limit':0x1,'order':[[_0x998f('0x78'),_0x998f('0x82')]]}]}]})['then'](handleEntityNotFound(_0x2ce5d4,null))[_0x998f('0x23')](function(_0x46e156){if(_0x46e156&&_0x46e156[_0x998f('0x84')]){_0x58ed8a=_0x46e156['get']({'plain':!![]});if(_0x58ed8a['List']&&_0x58ed8a['List'][_0x998f('0x81')][_0x998f('0x57')]){return _0x58ed8a[_0x998f('0x84')]['Contacts'][0x0];}return db['CmContact'][_0x998f('0x58')](_[_0x998f('0x19')](_0x450082['body'],{'firstName':_0x303062,[_0x46e156['mapKey']]:_0x303062,'phone':_0x303062,'ListId':_0x58ed8a[_0x998f('0x89')]}));}})['then'](handleEntityNotFound(_0x2ce5d4,null))[_0x998f('0x23')](function(_0x5e3e48){if(_0x5e3e48){_0x44c74e=_0x5e3e48;return db[_0x998f('0x8e')]['find']({'where':{'ContactId':_0x44c74e['id'],'closed':![],'OpenchannelAccountId':_0x58ed8a['id']}})['then'](function(_0x305ea0){if(_0x305ea0){return[_0x305ea0,![]];}return db[_0x998f('0x8e')][_0x998f('0x58')]({'UserId':_0x450082['user']['id'],'ContactId':_0x44c74e['id'],'OpenchannelAccountId':_0x58ed8a['id'],'lastMsgDirection':'out','Messages':[_['merge'](_0x450082[_0x998f('0x59')],{'read':![],'body':_0x450082[_0x998f('0x59')][_0x998f('0x59')],'OpenchannelAccountId':_0x58ed8a['id'],'UserId':_0x450082[_0x998f('0x5a')]['id'],'ContactId':_0x44c74e['id']})]},{'include':[{'model':db[_0x998f('0x98')],'as':_0x998f('0xb9')}]})[_0x998f('0x23')](function(_0x39c96b){return[_0x39c96b,!![]];});});}})[_0x998f('0x91')](function(_0x2cca3f,_0x552a23){if(_0x552a23){return _0x2cca3f;}return db[_0x998f('0x98')][_0x998f('0x58')](_[_0x998f('0x4e')](_0x450082['body'],{'read':![],'body':_0x450082['body'][_0x998f('0x59')],'OpenchannelAccountId':_0x58ed8a['id'],'OpenchannelInteractionId':_0x2cca3f['id'],'UserId':_0x450082[_0x998f('0x5a')]['id'],'ContactId':_0x44c74e['id']}))[_0x998f('0x23')](function(_0x5da56e){_0x2cca3f[_0x998f('0xba')][_0x998f('0xb9')]=[];_0x2cca3f[_0x998f('0xba')][_0x998f('0xb9')][_0x998f('0x96')](_0x5da56e[_0x998f('0xba')]);return _0x2cca3f;});});}})['then'](respondWithResult(_0x2ce5d4,null))[_0x998f('0x29')](handleError(_0x2ce5d4,null));};
\ No newline at end of file