Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index 2e561b3..eb94701 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x326f=['getApplications','getInteractions','Contact','fullname','internal','Tag','Tags','color','tag','addAgents','omit','emit','userOpenchannelAccount:save','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','out','dataValues','Messages','push','html-pdf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./openchannelAccount.socket','jayson/promise','client','http','request','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','sendStatus','end','status','offset','limit','set','Content-Range','json','apply','reject','save','update','destroy','get','OpenchannelAccounts','stack','name','send','Pause','mandatoryDispositionPause','map','OpenchannelAccount','fieldName','model','query','filters','intersection','attributes','fields','length','nolimit','sort','where','merge','type','VIRTUAL','filter','options','count','includeAll','include','findAll','rows','catch','params','keys','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','OpenchannelAccountId','findOne','Disposition','rawAttributes','hasOwnProperty','order','pick','ids','CannedAnswer','getAnswers','removeAnswers','notify','openchannel','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','isNil','from','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC','Applications','account','applications','list','orderBy','priority','asc','ListId','contact','lastName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','firstName','messageId','interaction','created','autoclose','close','OpenchannelMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','sequelize','transaction','OpenchannelApplication','bulkCreate','findAndCountAll'];(function(_0x106214,_0x454b8d){var _0x5f5cea=function(_0x247841){while(--_0x247841){_0x106214['push'](_0x106214['shift']());}};_0x5f5cea(++_0x454b8d);}(_0x326f,0xd1));var _0xf326=function(_0x183e60,_0x4248aa){_0x183e60=_0x183e60-0x0;var _0x316f69=_0x326f[_0x183e60];return _0x316f69;};'use strict';var pdf=require(_0xf326('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf326('0x1'));var jsonpatch=require(_0xf326('0x2'));var rp=require(_0xf326('0x3'));var moment=require(_0xf326('0x4'));var BPromise=require(_0xf326('0x5'));var Mustache=require(_0xf326('0x6'));var util=require(_0xf326('0x7'));var path=require(_0xf326('0x8'));var sox=require(_0xf326('0x9'));var csv=require(_0xf326('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf326('0xb'));var squel=require(_0xf326('0xc'));var crypto=require(_0xf326('0xd'));var jsforce=require(_0xf326('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf326('0xf'));var Redis=require(_0xf326('0x10'));var authService=require(_0xf326('0x11'));var qs=require(_0xf326('0x12'));var as=require(_0xf326('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf326('0x14'))('api');var utils=require(_0xf326('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf326('0x16'));var db=require('../../mysqldb')['db'];config[_0xf326('0x17')]=_[_0xf326('0x18')](config['redis'],{'host':_0xf326('0x19'),'port':0x18eb});var socket=require(_0xf326('0x1a'))(new Redis(config[_0xf326('0x17')]));require(_0xf326('0x1b'))['register'](socket);var jayson=require(_0xf326('0x1c'));var client=jayson['client']['http']({'port':0x232c});var client9002=jayson[_0xf326('0x1d')][_0xf326('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x1f2e5a,_0xa63d1a,_0x292f4b,_0x287a2a){return new BPromise(function(_0x34128e,_0x2cf2ca){var _0x5a682a=_0x287a2a||client;return _0x5a682a[_0xf326('0x1f')](_0x1f2e5a,_0x292f4b)[_0xf326('0x20')](function(_0x18bee3){logger[_0xf326('0x21')](_0xf326('0x22'),_0xa63d1a,_0xf326('0x23'));logger['debug']('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0xa63d1a,'request\x20sent',JSON[_0xf326('0x24')](_0x18bee3));if(_0x18bee3[_0xf326('0x25')]){if(_0x18bee3['error']['code']===0x1f4){logger[_0xf326('0x25')]('OpenchannelAccount,\x20%s,\x20%s',_0xa63d1a,_0x18bee3['error'][_0xf326('0x26')]);return _0x2cf2ca(_0x18bee3[_0xf326('0x25')]['message']);}logger['error'](_0xf326('0x22'),_0xa63d1a,_0x18bee3[_0xf326('0x25')]['message']);return _0x34128e(_0x18bee3[_0xf326('0x25')][_0xf326('0x26')]);}else{logger[_0xf326('0x21')](_0xf326('0x22'),_0xa63d1a,_0xf326('0x23'));_0x34128e(_0x18bee3[_0xf326('0x27')]['message']);}})['catch'](function(_0x4f31f6){logger[_0xf326('0x25')](_0xf326('0x22'),_0xa63d1a,_0x4f31f6);_0x2cf2ca(_0x4f31f6);});});}function respondWithStatusCode(_0x2cd45a,_0x1ff2b5){_0x1ff2b5=_0x1ff2b5||0xcc;return function(_0x148953){if(_0x148953){return _0x2cd45a[_0xf326('0x28')](_0x1ff2b5);}return _0x2cd45a['status'](_0x1ff2b5)[_0xf326('0x29')]();};}function respondWithResult(_0xa3c0b,_0x212d5d){_0x212d5d=_0x212d5d||0xc8;return function(_0x581531){if(_0x581531){return _0xa3c0b[_0xf326('0x2a')](_0x212d5d)['json'](_0x581531);}};}function respondWithFilteredResult(_0x4a9abf,_0x6a8e89){return function(_0x1ae23a){if(_0x1ae23a){var _0x2fa28e=_0x1ae23a['count'],_0x5dbe63=_0x6a8e89[_0xf326('0x2b')],_0xc115d9=_0x6a8e89[_0xf326('0x2b')]+_0x6a8e89[_0xf326('0x2c')],_0x292500;if(_0xc115d9>=_0x2fa28e){_0xc115d9=_0x2fa28e;_0x292500=0xc8;}else{_0x292500=0xce;}_0x4a9abf[_0xf326('0x2a')](_0x292500);return _0x4a9abf[_0xf326('0x2d')](_0xf326('0x2e'),_0x5dbe63+'-'+_0xc115d9+'/'+_0x2fa28e)[_0xf326('0x2f')](_0x1ae23a);}return null;};}function patchUpdates(_0x39a1e2){return function(_0x43b951){try{jsonpatch[_0xf326('0x30')](_0x43b951,_0x39a1e2,!![]);}catch(_0x4b52f2){return BPromise[_0xf326('0x31')](_0x4b52f2);}return _0x43b951[_0xf326('0x32')]();};}function saveUpdates(_0x21b23d,_0x4792d2){return function(_0x2c0cac){if(_0x2c0cac){return _0x2c0cac[_0xf326('0x33')](_0x21b23d)[_0xf326('0x20')](function(_0x4df451){return _0x4df451;});}return null;};}function removeEntity(_0x5b101d,_0x2b8b31){return function(_0x46d75e){if(_0x46d75e){return _0x46d75e[_0xf326('0x34')]()[_0xf326('0x20')](function(){var _0x30694f=_0x46d75e[_0xf326('0x35')]({'plain':!![]});var _0x62585a=_0xf326('0x36');return db['UserProfileResource'][_0xf326('0x34')]({'where':{'type':_0x62585a,'resourceId':_0x30694f['id']}})[_0xf326('0x20')](function(){return _0x46d75e;});})['then'](function(){_0x5b101d[_0xf326('0x2a')](0xcc)['end']();});}};}function handleEntityNotFound(_0xce1cbb,_0x481b64){return function(_0x51f147){if(!_0x51f147){_0xce1cbb[_0xf326('0x28')](0x194);}return _0x51f147;};}function handleError(_0x4d8eac,_0x40dcb4){_0x40dcb4=_0x40dcb4||0x1f4;return function(_0x57aa27){logger[_0xf326('0x25')](_0x57aa27[_0xf326('0x37')]);if(_0x57aa27[_0xf326('0x38')]){delete _0x57aa27['name'];}_0x4d8eac[_0xf326('0x2a')](_0x40dcb4)[_0xf326('0x39')](_0x57aa27);};}exports['index']=function(_0x13932b,_0xf64dd0){var _0x40fa7a={'include':[{'model':db[_0xf326('0x3a')],'as':_0xf326('0x3b')}]},_0xaf65e0={},_0x51076c={'count':0x0,'rows':[]};var _0x1e69b1=_[_0xf326('0x3c')](db[_0xf326('0x3d')]['rawAttributes'],function(_0x3e830d){return{'name':_0x3e830d[_0xf326('0x3e')],'type':_0x3e830d['type']['key']};});_0xaf65e0[_0xf326('0x3f')]=_['map'](_0x1e69b1,'name');_0xaf65e0[_0xf326('0x40')]=_['keys'](_0x13932b[_0xf326('0x40')]);_0xaf65e0[_0xf326('0x41')]=_[_0xf326('0x42')](_0xaf65e0[_0xf326('0x3f')],_0xaf65e0['query']);_0x40fa7a[_0xf326('0x43')]=_[_0xf326('0x42')](_0xaf65e0[_0xf326('0x3f')],qs[_0xf326('0x44')](_0x13932b[_0xf326('0x40')][_0xf326('0x44')]));_0x40fa7a[_0xf326('0x43')]=_0x40fa7a[_0xf326('0x43')][_0xf326('0x45')]?_0x40fa7a[_0xf326('0x43')]:_0xaf65e0[_0xf326('0x3f')];if(!_0x13932b[_0xf326('0x40')]['hasOwnProperty'](_0xf326('0x46'))){_0x40fa7a[_0xf326('0x2c')]=qs[_0xf326('0x2c')](_0x13932b[_0xf326('0x40')][_0xf326('0x2c')]);_0x40fa7a[_0xf326('0x2b')]=qs['offset'](_0x13932b[_0xf326('0x40')][_0xf326('0x2b')]);}_0x40fa7a['order']=qs[_0xf326('0x47')](_0x13932b[_0xf326('0x40')][_0xf326('0x47')]);_0x40fa7a[_0xf326('0x48')]=qs[_0xf326('0x41')](_['pick'](_0x13932b['query'],_0xaf65e0[_0xf326('0x41')]),_0x1e69b1);if(_0x13932b[_0xf326('0x40')]['filter']){_0x40fa7a['where']=_[_0xf326('0x49')](_0x40fa7a[_0xf326('0x48')],{'$or':_[_0xf326('0x3c')](_0x1e69b1,function(_0x5b3705){if(_0x5b3705[_0xf326('0x4a')]!==_0xf326('0x4b')){var _0x2180d6={};_0x2180d6[_0x5b3705[_0xf326('0x38')]]={'$like':'%'+_0x13932b[_0xf326('0x40')][_0xf326('0x4c')]+'%'};return _0x2180d6;}})});}_0x40fa7a=_[_0xf326('0x49')]({},_0x40fa7a,_0x13932b[_0xf326('0x4d')]);var _0x3df9a8={'where':_0x40fa7a[_0xf326('0x48')]};return db[_0xf326('0x3d')][_0xf326('0x4e')](_0x3df9a8)[_0xf326('0x20')](function(_0x395b1e){_0x51076c[_0xf326('0x4e')]=_0x395b1e;if(_0x13932b['query'][_0xf326('0x4f')]){_0x40fa7a[_0xf326('0x50')]=[{'all':!![]}];}return db[_0xf326('0x3d')][_0xf326('0x51')](_0x40fa7a);})['then'](function(_0x10f437){_0x51076c[_0xf326('0x52')]=_0x10f437;return _0x51076c;})[_0xf326('0x20')](respondWithFilteredResult(_0xf64dd0,_0x40fa7a))[_0xf326('0x53')](handleError(_0xf64dd0,null));};exports['show']=function(_0x30a356,_0x1967ab){var _0x145a77={'raw':![],'where':{'id':_0x30a356[_0xf326('0x54')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x451ac7={};_0x451ac7[_0xf326('0x3f')]=_[_0xf326('0x55')](db[_0xf326('0x3d')]['rawAttributes']);_0x451ac7[_0xf326('0x40')]=_[_0xf326('0x55')](_0x30a356[_0xf326('0x40')]);_0x451ac7['filters']=_['intersection'](_0x451ac7[_0xf326('0x3f')],_0x451ac7['query']);_0x145a77[_0xf326('0x43')]=_['intersection'](_0x451ac7[_0xf326('0x3f')],qs[_0xf326('0x44')](_0x30a356[_0xf326('0x40')][_0xf326('0x44')]));_0x145a77[_0xf326('0x43')]=_0x145a77[_0xf326('0x43')][_0xf326('0x45')]?_0x145a77['attributes']:_0x451ac7[_0xf326('0x3f')];if(_0x30a356[_0xf326('0x40')][_0xf326('0x4f')]){_0x145a77['include']=[{'all':!![]}];}_0x145a77=_[_0xf326('0x49')]({},_0x145a77,_0x30a356[_0xf326('0x4d')]);return db[_0xf326('0x3d')][_0xf326('0x56')](_0x145a77)[_0xf326('0x20')](handleEntityNotFound(_0x1967ab,null))['then'](respondWithResult(_0x1967ab,null))[_0xf326('0x53')](handleError(_0x1967ab,null));};exports[_0xf326('0x57')]=function(_0x287a97,_0x46a21f){return db['OpenchannelAccount'][_0xf326('0x57')](_0x287a97[_0xf326('0x58')],{})[_0xf326('0x20')](function(_0x29e52e){var _0x4d3b9e=_0x287a97['user'][_0xf326('0x35')]({'plain':!![]});if(!_0x4d3b9e)throw new Error(_0xf326('0x59'));if(_0x4d3b9e['role']===_0xf326('0x5a')){var _0x29de71=_0x29e52e[_0xf326('0x35')]({'plain':!![]});var _0x1258d1='OpenchannelAccounts';return db[_0xf326('0x5b')]['find']({'where':{'name':_0x1258d1,'userProfileId':_0x4d3b9e['userProfileId']},'raw':!![]})[_0xf326('0x20')](function(_0x51d466){if(_0x51d466&&_0x51d466[_0xf326('0x5c')]===0x0){return db[_0xf326('0x5d')][_0xf326('0x57')]({'name':_0x29de71['name'],'resourceId':_0x29de71['id'],'type':_0x51d466['name'],'sectionId':_0x51d466['id']},{})[_0xf326('0x20')](function(){return _0x29e52e;});}else{return _0x29e52e;}})[_0xf326('0x53')](function(_0x33b259){logger['error'](_0xf326('0x5e'),_0x33b259);throw _0x33b259;});}return _0x29e52e;})['then'](respondWithResult(_0x46a21f,0xc9))[_0xf326('0x53')](handleError(_0x46a21f,null));};exports[_0xf326('0x33')]=function(_0x131184,_0x217897){if(_0x131184[_0xf326('0x58')]['id']){delete _0x131184[_0xf326('0x58')]['id'];}return db[_0xf326('0x3d')][_0xf326('0x56')]({'where':{'id':_0x131184[_0xf326('0x54')]['id']},'include':[{'model':db[_0xf326('0x3a')],'as':_0xf326('0x3b')}]})[_0xf326('0x20')](handleEntityNotFound(_0x217897,null))[_0xf326('0x20')](saveUpdates(_0x131184['body'],null))[_0xf326('0x20')](respondWithResult(_0x217897,null))['catch'](handleError(_0x217897,null));};exports[_0xf326('0x34')]=function(_0x32d173,_0x5e858d){return db[_0xf326('0x3d')]['find']({'where':{'id':_0x32d173[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x5e858d,null))[_0xf326('0x20')](removeEntity(_0x5e858d,null))[_0xf326('0x53')](handleError(_0x5e858d,null));};exports[_0xf326('0x5f')]=function(_0x51ff5e,_0x4ec099){return db[_0xf326('0x3d')][_0xf326('0x5f')]()[_0xf326('0x20')](respondWithResult(_0x4ec099,null))[_0xf326('0x53')](handleError(_0x4ec099,null));};exports[_0xf326('0x60')]=function(_0x579d2c,_0x28c4f2,_0x471da8){if(_0x579d2c['body']['id']){delete _0x579d2c['body']['id'];}return db['OpenchannelAccount'][_0xf326('0x56')]({'where':{'id':_0x579d2c[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x28c4f2,null))[_0xf326('0x20')](function(_0x240ce5){if(_0x240ce5){_0x579d2c[_0xf326('0x58')][_0xf326('0x61')]=_0x240ce5['id'];return db['Disposition'][_0xf326('0x57')](_0x579d2c[_0xf326('0x58')]);}})[_0xf326('0x20')](respondWithResult(_0x28c4f2,null))[_0xf326('0x53')](handleError(_0x28c4f2,null));};exports['getDispositions']=function(_0x3717fe,_0x5eebe8,_0x499b59){var _0x2dd9e4={'raw':![],'where':{}};var _0x540fa0={};var _0x78ba34={'count':0x0,'rows':[]};return db[_0xf326('0x3d')][_0xf326('0x62')]({'where':{'id':_0x3717fe[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x5eebe8,null))['then'](function(_0x4a053c){if(_0x4a053c){_0x540fa0['model']=_[_0xf326('0x55')](db[_0xf326('0x63')][_0xf326('0x64')]);_0x540fa0[_0xf326('0x40')]=_[_0xf326('0x55')](_0x3717fe['query']);_0x540fa0[_0xf326('0x41')]=_[_0xf326('0x42')](_0x540fa0[_0xf326('0x3f')],_0x540fa0['query']);_0x2dd9e4['attributes']=_[_0xf326('0x42')](_0x540fa0[_0xf326('0x3f')],qs['fields'](_0x3717fe['query'][_0xf326('0x44')]));_0x2dd9e4['attributes']=_0x2dd9e4[_0xf326('0x43')]['length']?_0x2dd9e4['attributes']:_0x540fa0['model'];if(!_0x3717fe[_0xf326('0x40')][_0xf326('0x65')](_0xf326('0x46'))){_0x2dd9e4['limit']=qs[_0xf326('0x2c')](_0x3717fe[_0xf326('0x40')][_0xf326('0x2c')]);_0x2dd9e4[_0xf326('0x2b')]=qs[_0xf326('0x2b')](_0x3717fe[_0xf326('0x40')][_0xf326('0x2b')]);}_0x2dd9e4[_0xf326('0x66')]=qs[_0xf326('0x47')](_0x3717fe['query'][_0xf326('0x47')]);_0x2dd9e4['where']=qs[_0xf326('0x41')](_[_0xf326('0x67')](_0x3717fe[_0xf326('0x40')],_0x540fa0['filters']));_0x2dd9e4[_0xf326('0x48')][_0xf326('0x61')]=_0x4a053c['id'];if(_0x3717fe[_0xf326('0x40')]['filter']){_0x2dd9e4[_0xf326('0x48')]=_[_0xf326('0x49')](_0x2dd9e4[_0xf326('0x48')],{'$or':_[_0xf326('0x3c')](_0x2dd9e4['attributes'],function(_0x3addac){var _0x5c9900={};_0x5c9900[_0x3addac]={'$like':'%'+_0x3717fe['query'][_0xf326('0x4c')]+'%'};return _0x5c9900;})});}_0x2dd9e4=_[_0xf326('0x49')]({},_0x2dd9e4,_0x3717fe['options']);return db['Disposition']['count']({'where':_0x2dd9e4[_0xf326('0x48')]})['then'](function(_0x102d03){_0x78ba34[_0xf326('0x4e')]=_0x102d03;if(_0x3717fe[_0xf326('0x40')][_0xf326('0x4f')]){_0x2dd9e4[_0xf326('0x50')]=[{'all':!![]}];}return db[_0xf326('0x63')]['findAll'](_0x2dd9e4);})[_0xf326('0x20')](function(_0x323926){_0x78ba34['rows']=_0x323926;return _0x78ba34;});}})['then'](respondWithFilteredResult(_0x5eebe8,_0x2dd9e4))[_0xf326('0x53')](handleError(_0x5eebe8,null));};exports['removeDispositions']=function(_0x35a7c9,_0x147d51,_0x153027){return db[_0xf326('0x3d')][_0xf326('0x56')]({'where':{'id':_0x35a7c9[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x147d51,null))[_0xf326('0x20')](function(_0x9bd3a4){if(_0x9bd3a4){return _0x9bd3a4['removeDispositions'](_0x35a7c9[_0xf326('0x40')][_0xf326('0x68')]);}})['then'](respondWithStatusCode(_0x147d51,null))[_0xf326('0x53')](handleError(_0x147d51,null));};exports['addAnswer']=function(_0x28763a,_0x34fe36,_0x14e8c0){if(_0x28763a['body']['id']){delete _0x28763a[_0xf326('0x58')]['id'];}return db[_0xf326('0x3d')][_0xf326('0x56')]({'where':{'id':_0x28763a[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x34fe36,null))[_0xf326('0x20')](function(_0x148779){if(_0x148779){_0x28763a[_0xf326('0x58')][_0xf326('0x61')]=_0x148779['id'];return db[_0xf326('0x69')][_0xf326('0x57')](_0x28763a[_0xf326('0x58')]);}})[_0xf326('0x20')](respondWithResult(_0x34fe36,null))[_0xf326('0x53')](handleError(_0x34fe36,null));};exports[_0xf326('0x6a')]=function(_0x53e75f,_0x3bec1e,_0x24aaca){var _0x4829ae={'raw':![],'where':{}};var _0x438daa={};var _0x424be4={'count':0x0,'rows':[]};return db['OpenchannelAccount'][_0xf326('0x62')]({'where':{'id':_0x53e75f[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x3bec1e,null))[_0xf326('0x20')](function(_0x2ab607){if(_0x2ab607){_0x438daa[_0xf326('0x3f')]=_[_0xf326('0x55')](db['CannedAnswer'][_0xf326('0x64')]);_0x438daa[_0xf326('0x40')]=_[_0xf326('0x55')](_0x53e75f[_0xf326('0x40')]);_0x438daa[_0xf326('0x41')]=_[_0xf326('0x42')](_0x438daa[_0xf326('0x3f')],_0x438daa[_0xf326('0x40')]);_0x4829ae['attributes']=_[_0xf326('0x42')](_0x438daa[_0xf326('0x3f')],qs['fields'](_0x53e75f[_0xf326('0x40')]['fields']));_0x4829ae[_0xf326('0x43')]=_0x4829ae[_0xf326('0x43')][_0xf326('0x45')]?_0x4829ae[_0xf326('0x43')]:_0x438daa[_0xf326('0x3f')];if(!_0x53e75f[_0xf326('0x40')][_0xf326('0x65')](_0xf326('0x46'))){_0x4829ae[_0xf326('0x2c')]=qs[_0xf326('0x2c')](_0x53e75f[_0xf326('0x40')][_0xf326('0x2c')]);_0x4829ae[_0xf326('0x2b')]=qs[_0xf326('0x2b')](_0x53e75f['query'][_0xf326('0x2b')]);}_0x4829ae[_0xf326('0x66')]=qs[_0xf326('0x47')](_0x53e75f[_0xf326('0x40')][_0xf326('0x47')]);_0x4829ae['where']=qs[_0xf326('0x41')](_[_0xf326('0x67')](_0x53e75f[_0xf326('0x40')],_0x438daa[_0xf326('0x41')]));_0x4829ae[_0xf326('0x48')]['OpenchannelAccountId']=_0x2ab607['id'];if(_0x53e75f['query'][_0xf326('0x4c')]){_0x4829ae['where']=_[_0xf326('0x49')](_0x4829ae[_0xf326('0x48')],{'$or':_[_0xf326('0x3c')](_0x4829ae['attributes'],function(_0x54b023){var _0x386c4c={};_0x386c4c[_0x54b023]={'$like':'%'+_0x53e75f[_0xf326('0x40')][_0xf326('0x4c')]+'%'};return _0x386c4c;})});}_0x4829ae=_[_0xf326('0x49')]({},_0x4829ae,_0x53e75f[_0xf326('0x4d')]);return db['CannedAnswer'][_0xf326('0x4e')]({'where':_0x4829ae[_0xf326('0x48')]})[_0xf326('0x20')](function(_0x5a11c3){_0x424be4['count']=_0x5a11c3;if(_0x53e75f['query'][_0xf326('0x4f')]){_0x4829ae[_0xf326('0x50')]=[{'all':!![]}];}return db[_0xf326('0x69')][_0xf326('0x51')](_0x4829ae);})[_0xf326('0x20')](function(_0x224c7b){_0x424be4[_0xf326('0x52')]=_0x224c7b;return _0x424be4;});}})['then'](respondWithFilteredResult(_0x3bec1e,_0x4829ae))['catch'](handleError(_0x3bec1e,null));};exports[_0xf326('0x6b')]=function(_0x228c81,_0x471982,_0x571b8c){return db[_0xf326('0x3d')][_0xf326('0x56')]({'where':{'id':_0x228c81[_0xf326('0x54')]['id']}})['then'](handleEntityNotFound(_0x471982,null))[_0xf326('0x20')](function(_0x438733){if(_0x438733){return _0x438733[_0xf326('0x6b')](_0x228c81[_0xf326('0x40')]['ids']);}})['then'](respondWithStatusCode(_0x471982,null))['catch'](handleError(_0x471982,null));};exports[_0xf326('0x6c')]=function(_0x3c6435,_0x35dc32,_0x5f0b45){var _0xb64659={'body':_0x3c6435[_0xf326('0x58')],'channel':_0xf326('0x6d')};var _0x568015=[];var _0x2ce36b=[];var _0x2c12bb={};var _0xbec94=![];return db[_0xf326('0x6e')]['describe']()[_0xf326('0x20')](function(_0x5ee536){if(!_0x5ee536){throw new db[(_0xf326('0x6f'))][(_0xf326('0x70'))](_0xf326('0x71'));}_0x568015=_[_0xf326('0x72')](_['keys'](_0x5ee536),[_0xf326('0x73'),'updatedAt']);_0x2ce36b=_[_0xf326('0x72')](_[_0xf326('0x55')](_0x5ee536),[_0xf326('0x73'),_0xf326('0x74'),_0xf326('0x75'),'ListId']);if(_0x3c6435['body']['id']){delete _0x3c6435[_0xf326('0x58')]['id'];}if(_[_0xf326('0x76')](_0x3c6435[_0xf326('0x58')][_0xf326('0x77')])){throw new db['Sequelize'][(_0xf326('0x70'))]('from\x20is\x20mandatory');}if(_[_0xf326('0x76')](_0x3c6435[_0xf326('0x58')][_0xf326('0x58')])||_0x3c6435['body'][_0xf326('0x58')]===''){throw new db[(_0xf326('0x6f'))][(_0xf326('0x70'))](_0xf326('0x78'));}if(_[_0xf326('0x76')](_0x3c6435['body'][_0xf326('0x79')])){throw new db[(_0xf326('0x6f'))]['ValidationError'](_0xf326('0x7a')+_0x2ce36b);}if(!_[_0xf326('0x7b')](_0x2ce36b,_0x3c6435[_0xf326('0x58')][_0xf326('0x79')])){throw new db['Sequelize']['ValidationError'](_0xf326('0x7c')+_0x2ce36b);}_0x2c12bb[_0x3c6435[_0xf326('0x58')]['mapKey']]=_0x3c6435[_0xf326('0x58')]['from'];})['then'](function(){return db[_0xf326('0x3d')][_0xf326('0x56')]({'where':{'id':_0x3c6435[_0xf326('0x54')]['id']},'include':[{'model':db[_0xf326('0x7d')],'as':_0xf326('0x7e'),'include':[{'model':db[_0xf326('0x6e')],'as':_0xf326('0x7f'),'where':_0x2c12bb,'limit':0x1,'order':[[_0xf326('0x74'),_0xf326('0x80')]]}]},{'model':db['OpenchannelApplication'],'as':_0xf326('0x81')}]});})[_0xf326('0x20')](handleEntityNotFound(_0x35dc32,null))[_0xf326('0x20')](function(_0x1c7f81){if(_0x1c7f81&&_0x1c7f81['List']){_0xb64659[_0xf326('0x82')]=_0x1c7f81;_0xb64659[_0xf326('0x83')]=_0x1c7f81[_0xf326('0x81')];_0xb64659[_0xf326('0x84')]=_0x1c7f81[_0xf326('0x7e')];_0xb64659['applications']=_[_0xf326('0x85')](_0xb64659['applications'],[_0xf326('0x86')],[_0xf326('0x87')]);if(_0xb64659[_0xf326('0x82')][_0xf326('0x81')]){delete _0xb64659['account'][_0xf326('0x81')];}if(_0xb64659[_0xf326('0x82')][_0xf326('0x7e')]&&_0xb64659['account'][_0xf326('0x7e')][_0xf326('0x7f')][_0xf326('0x45')]){return _0xb64659[_0xf326('0x82')]['List'][_0xf326('0x7f')][0x0];}var _0x1ee591=_[_0xf326('0x18')](_0x3c6435[_0xf326('0x58')],{'firstName':_0x3c6435['body'][_0xf326('0x77')],'ListId':_0x1c7f81[_0xf326('0x88')]});_0x1ee591[_0x3c6435[_0xf326('0x58')]['mapKey']]=_0x3c6435[_0xf326('0x58')][_0xf326('0x77')];return db['CmContact'][_0xf326('0x57')](_0x1ee591,{'fields':_0x568015,'raw':!![]});}})[_0xf326('0x20')](handleEntityNotFound(_0x35dc32,null))[_0xf326('0x20')](function(_0x22f5a3){_0xb64659[_0xf326('0x89')]=_0x22f5a3;if(_0x22f5a3){var _0x26d4b4={'ContactId':_0x22f5a3['id'],'OpenchannelAccountId':_0x3c6435['params']['id'],'from':(_0x22f5a3['firstName']||'')+'\x20'+(_0x22f5a3[_0xf326('0x8a')]||'')};var _0x21ec87={'OpenchannelAccountId':_0x3c6435[_0xf326('0x54')]['id'],'closed':![]};if(_0x3c6435[_0xf326('0x58')][_0xf326('0x8b')]){_0x21ec87[_0xf326('0x8b')]=_0x3c6435['body'][_0xf326('0x8b')];return db[_0xf326('0x8c')][_0xf326('0x56')]({'where':_0x21ec87})[_0xf326('0x20')](function(_0x50d506){if(_0x50d506){return[_0x50d506,![]];}_0x26d4b4[_0xf326('0x8b')]=_0x3c6435[_0xf326('0x58')][_0xf326('0x8b')];_0x26d4b4[_0xf326('0x8d')]=_0x3c6435['body'][_0xf326('0x8d')];return db['OpenchannelInteraction']['create'](_0x26d4b4)[_0xf326('0x20')](function(_0x549a1f){return[_0x549a1f,!![]];});});}else{_0x21ec87[_0xf326('0x8b')]=null;}_0x21ec87[_0xf326('0x8e')]=_0x22f5a3['id'];return db[_0xf326('0x8c')][_0xf326('0x56')]({'where':_0x21ec87})[_0xf326('0x20')](function(_0x84f9ad){if(_0x84f9ad){return[_0x84f9ad,![]];}return db[_0xf326('0x8c')][_0xf326('0x57')](_0x26d4b4)[_0xf326('0x20')](function(_0x314442){return[_0x314442,!![]];});});}})[_0xf326('0x8f')](function(_0x4371f7,_0x4c1fcd){if(_0x4371f7){_0xbec94=_0x4c1fcd;if(!_0x4c1fcd){var _0x537b10={'from':(_0xb64659[_0xf326('0x89')][_0xf326('0x90')]||'')+'\x20'+(_0xb64659[_0xf326('0x89')][_0xf326('0x8a')]||'')};if(_0x3c6435[_0xf326('0x58')][_0xf326('0x8b')]&&_0x3c6435['body'][_0xf326('0x91')]&&_0x3c6435[_0xf326('0x58')][_0xf326('0x8b')]!=_0x3c6435[_0xf326('0x58')][_0xf326('0x91')]){_0x537b10[_0xf326('0x8b')]=_0x3c6435[_0xf326('0x58')]['messageId'];}return _0x4371f7[_0xf326('0x33')](_0x537b10);}else{return _0x4371f7;}}})[_0xf326('0x20')](function(_0x149aea){_0xb64659[_0xf326('0x92')]=_0x149aea[_0xf326('0x35')]({'plain':!![]});_0xb64659[_0xf326('0x92')][_0xf326('0x93')]=_0xbec94;if(_0xb64659[_0xf326('0x92')][_0xf326('0x93')]){if(_0xb64659[_0xf326('0x82')][_0xf326('0x94')]){_0xb64659[_0xf326('0x83')]['push']({'id':0x0,'priority':_0xb64659[_0xf326('0x83')][_0xf326('0x45')]+0x1,'app':_0xf326('0x95'),'appdata':'unmanaged','interval':'*,*,*,*'});}}return db[_0xf326('0x96')][_0xf326('0x57')]({'body':_0x3c6435[_0xf326('0x58')][_0xf326('0x58')],'OpenchannelAccountId':_0x3c6435['params']['id'],'OpenchannelInteractionId':_0x149aea['id'],'direction':'in','ContactId':_0xb64659[_0xf326('0x89')]['id'],'AttachmentId':_0x3c6435[_0xf326('0x58')][_0xf326('0x97')]});})['then'](function(_0x48bc4d){_0xb64659['message']=_0x48bc4d;if(_0xb64659[_0xf326('0x92')][_0xf326('0x98')]){return db[_0xf326('0x99')]['find']({'attributes':['id',_0xf326('0x38')],'where':{'id':_0xb64659['interaction'][_0xf326('0x98')]}})['then'](function(_0x4f479){if(_0x4f479){_0xb64659[_0xf326('0x83')][_0xf326('0x9a')]({'id':0x0,'priority':0x0,'app':_0xf326('0x9b'),'appdata':_0x4f479[_0xf326('0x38')]+','+(_0xb64659[_0xf326('0x82')][_0xf326('0x9c')]||0xa),'interval':_0xf326('0x9d')});_0xb64659[_0xf326('0x9e')]=![];}return respondWithRpcPromise(_0xf326('0x9f'),_0xf326('0xa0'),_0xb64659);});}return respondWithRpcPromise(_0xf326('0x9f'),_0xf326('0xa0'),_0xb64659);})[_0xf326('0x20')](function(_0x49df87){respondWithRpcPromise(_0xf326('0xa1'),_0xf326('0xa1'),{'event':_0xf326('0x6c'),'message':_0x49df87},client9002);return _0x49df87;})['then'](respondWithResult(_0x35dc32,null))['catch'](handleError(_0x35dc32,null));};exports['addApplications']=function(_0x3fc996,_0xac3f28,_0x29f0bc){return db[_0xf326('0x3d')][_0xf326('0x62')]({'where':{'id':_0x3fc996[_0xf326('0x54')]['id']}})['then'](handleEntityNotFound(_0xac3f28,null))[_0xf326('0x20')](function(_0x13b421){if(_0x13b421){return db[_0xf326('0xa2')][_0xf326('0xa3')](function(_0x71e344){return db['OpenchannelApplication'][_0xf326('0x34')]({'where':{'OpenchannelAccountId':_0x3fc996[_0xf326('0x54')]['id']},'transaction':_0x71e344})[_0xf326('0x20')](function(_0x310f9a){var _0x350d76=_['map'](_0x3fc996['body'],function(_0x7f6c2d){_0x7f6c2d['OpenchannelAccountId']=_0x3fc996['params']['id'];return _0x7f6c2d;});return db[_0xf326('0xa4')][_0xf326('0xa5')](_0x350d76,{'transaction':_0x71e344});});})[_0xf326('0x20')](function(){return db[_0xf326('0xa4')][_0xf326('0xa6')]({'where':{'OpenchannelAccountId':_0x3fc996['params']['id']},'order':_0xf326('0x86')});});}})[_0xf326('0x20')](respondWithResult(_0xac3f28,null))[_0xf326('0x53')](handleError(_0xac3f28,null));};exports[_0xf326('0xa7')]=function(_0x507aac,_0x10a5e4,_0x48b178){var _0x4df691={};var _0x57c6c9={};var _0x4ee718;var _0x265395;return db[_0xf326('0x3d')][_0xf326('0x62')]({'where':{'id':_0x507aac[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x10a5e4,null))[_0xf326('0x20')](function(_0x3833f9){if(_0x3833f9){_0x4ee718=_0x3833f9;_0x57c6c9[_0xf326('0x3f')]=_[_0xf326('0x55')](db[_0xf326('0xa4')]['rawAttributes']);_0x57c6c9[_0xf326('0x40')]=_[_0xf326('0x55')](_0x507aac[_0xf326('0x40')]);_0x57c6c9[_0xf326('0x41')]=_[_0xf326('0x42')](_0x57c6c9[_0xf326('0x3f')],_0x57c6c9[_0xf326('0x40')]);_0x4df691[_0xf326('0x43')]=_[_0xf326('0x42')](_0x57c6c9['model'],qs[_0xf326('0x44')](_0x507aac[_0xf326('0x40')][_0xf326('0x44')]));_0x4df691['attributes']=_0x4df691['attributes'][_0xf326('0x45')]?_0x4df691[_0xf326('0x43')]:_0x57c6c9['model'];_0x4df691['order']=qs[_0xf326('0x47')](_0x507aac['query'][_0xf326('0x47')]);_0x4df691['where']=qs[_0xf326('0x41')](_[_0xf326('0x67')](_0x507aac[_0xf326('0x40')],_0x57c6c9[_0xf326('0x41')]));if(_0x507aac[_0xf326('0x40')]['filter']){_0x4df691[_0xf326('0x48')]=_['merge'](_0x4df691[_0xf326('0x48')],{'$or':_[_0xf326('0x3c')](_0x4df691[_0xf326('0x43')],function(_0x1b0826){var _0x76ad63={};_0x76ad63[_0x1b0826]={'$like':'%'+_0x507aac['query']['filter']+'%'};return _0x76ad63;})});}_0x4df691=_[_0xf326('0x49')]({},_0x4df691,_0x507aac['options']);return _0x4ee718['getApplications'](_0x4df691);}})['then'](function(_0x4ad24a){if(_0x4ad24a){_0x265395=_0x4ad24a[_0xf326('0x45')];if(!_0x507aac[_0xf326('0x40')][_0xf326('0x65')](_0xf326('0x46'))){_0x4df691[_0xf326('0x2c')]=qs[_0xf326('0x2c')](_0x507aac[_0xf326('0x40')][_0xf326('0x2c')]);_0x4df691[_0xf326('0x2b')]=qs[_0xf326('0x2b')](_0x507aac[_0xf326('0x40')]['offset']);}return _0x4ee718[_0xf326('0xa7')](_0x4df691);}})[_0xf326('0x20')](function(_0x1801fb){if(_0x1801fb){return _0x1801fb?{'count':_0x265395,'rows':_0x1801fb}:null;}})[_0xf326('0x20')](respondWithResult(_0x10a5e4,null))[_0xf326('0x53')](handleError(_0x10a5e4,null));};exports[_0xf326('0xa8')]=function(_0x221302,_0x21a36e,_0x1ec2de){var _0x536eda={'raw':![],'where':{}};var _0x2f99db={};var _0x5e9650={'count':0x0,'rows':[]};return db[_0xf326('0x3d')]['findOne']({'where':{'id':_0x221302['params']['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x21a36e,null))['then'](function(_0x3edec1){if(_0x3edec1){_0x2f99db[_0xf326('0x3f')]=_[_0xf326('0x55')](db[_0xf326('0x8c')]['rawAttributes']);_0x2f99db[_0xf326('0x40')]=_[_0xf326('0x55')](_0x221302[_0xf326('0x40')]);_0x2f99db[_0xf326('0x41')]=_['intersection'](_0x2f99db['model'],_0x2f99db[_0xf326('0x40')]);_0x536eda[_0xf326('0x43')]=_[_0xf326('0x42')](_0x2f99db[_0xf326('0x3f')],qs[_0xf326('0x44')](_0x221302[_0xf326('0x40')][_0xf326('0x44')]));_0x536eda[_0xf326('0x43')]=_0x536eda[_0xf326('0x43')][_0xf326('0x45')]?_0x536eda[_0xf326('0x43')]:_0x2f99db['model'];if(!_0x221302[_0xf326('0x40')][_0xf326('0x65')](_0xf326('0x46'))){_0x536eda['limit']=qs[_0xf326('0x2c')](_0x221302['query'][_0xf326('0x2c')]);_0x536eda[_0xf326('0x2b')]=qs['offset'](_0x221302[_0xf326('0x40')][_0xf326('0x2b')]);}_0x536eda[_0xf326('0x66')]=qs[_0xf326('0x47')](_0x221302['query'][_0xf326('0x47')]);_0x536eda[_0xf326('0x48')]=qs[_0xf326('0x41')](_[_0xf326('0x67')](_0x221302[_0xf326('0x40')],_0x2f99db['filters']));_0x536eda['where'][_0xf326('0x61')]=_0x3edec1['id'];if(_0x221302[_0xf326('0x40')][_0xf326('0x4c')]){_0x536eda[_0xf326('0x48')]=_[_0xf326('0x49')](_0x536eda[_0xf326('0x48')],{'$or':_[_0xf326('0x3c')](_0x536eda[_0xf326('0x43')],function(_0x3144c4){var _0x41034f={};_0x41034f[_0x3144c4]={'$like':'%'+_0x221302['query']['filter']+'%'};return _0x41034f;})});}_0x536eda=_[_0xf326('0x49')]({},_0x536eda,_0x221302[_0xf326('0x4d')]);return db[_0xf326('0x8c')][_0xf326('0x4e')]({'where':_0x536eda['where']})[_0xf326('0x20')](function(_0x1e2bfc){_0x5e9650[_0xf326('0x4e')]=_0x1e2bfc;if(_0x221302[_0xf326('0x40')][_0xf326('0x4f')]){_0x536eda[_0xf326('0x50')]=[{'model':db['CmContact'],'as':_0xf326('0xa9'),'required':![]},{'model':db['User'],'as':'Owner','attributes':[_0xf326('0x38'),_0xf326('0xaa'),_0xf326('0xab')],'required':![]},{'model':db[_0xf326('0xac')],'as':_0xf326('0xad'),'attributes':['id','name',_0xf326('0xae')],'where':_0x221302[_0xf326('0x40')][_0xf326('0xaf')]?{'id':_0x221302['query'][_0xf326('0xaf')]}:undefined,'required':_0x221302[_0xf326('0x40')][_0xf326('0xaf')]?!![]:![]}];}return db[_0xf326('0x8c')]['findAll'](_0x536eda);})[_0xf326('0x20')](function(_0x4815dd){_0x5e9650['rows']=_0x4815dd;return _0x5e9650;});}})[_0xf326('0x20')](respondWithFilteredResult(_0x21a36e,_0x536eda))['catch'](handleError(_0x21a36e,null));};exports['addAgents']=function(_0x329332,_0xbd7671,_0x2fad43){return db[_0xf326('0x3d')]['find']({'where':{'id':_0x329332['params']['id']}})[_0xf326('0x20')](handleEntityNotFound(_0xbd7671,null))[_0xf326('0x20')](function(_0x150022){if(_0x150022){return _0x150022[_0xf326('0xb0')](_0x329332[_0xf326('0x58')][_0xf326('0x68')],_[_0xf326('0xb1')](_0x329332[_0xf326('0x58')],[_0xf326('0x68'),'id'])||{})['spread'](function(_0x44fea7){for(var _0x5a8e2c=0x0;_0x5a8e2c<_0x329332[_0xf326('0x58')]['ids']['length'];_0x5a8e2c+=0x1){socket[_0xf326('0xb2')](_0xf326('0xb3'),{'UserId':_0x329332[_0xf326('0x58')][_0xf326('0x68')][_0x5a8e2c],'OpenchannelAccountId':_0x329332['params']['id']});}return _0x44fea7;});}})['then'](respondWithResult(_0xbd7671,null))['catch'](handleError(_0xbd7671,null));};exports[_0xf326('0xb4')]=function(_0x216c75,_0x730518,_0x59a37a){return db['OpenchannelAccount'][_0xf326('0x56')]({'where':{'id':_0x216c75[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x730518,null))['then'](function(_0x5b9be4){if(_0x5b9be4){return _0x5b9be4['removeAgents'](_0x216c75[_0xf326('0x40')][_0xf326('0x68')])[_0xf326('0x20')](function(){if(_[_0xf326('0xb5')](_0x216c75[_0xf326('0x40')][_0xf326('0x68')])){for(var _0x1f80ce=0x0;_0x1f80ce<_0x216c75[_0xf326('0x40')]['ids']['length'];_0x1f80ce+=0x1){socket[_0xf326('0xb2')]('userOpenchannelAccount:remove',{'UserId':Number(_0x216c75['query'][_0xf326('0x68')][_0x1f80ce]),'OpenchannelAccountId':Number(_0x216c75[_0xf326('0x54')]['id'])});}}else{socket[_0xf326('0xb2')](_0xf326('0xb6'),{'UserId':Number(_0x216c75[_0xf326('0x40')][_0xf326('0x68')]),'OpenchannelAccountId':Number(_0x216c75[_0xf326('0x54')]['id'])});}});}})[_0xf326('0x20')](respondWithStatusCode(_0x730518,null))[_0xf326('0x53')](handleError(_0x730518,null));};exports[_0xf326('0xb7')]=function(_0x392052,_0x12fc15,_0x5768b2){var _0x3b455d={};var _0x43685f={};var _0x2b6585;var _0x3d77af;return db['OpenchannelAccount'][_0xf326('0x62')]({'where':{'id':_0x392052[_0xf326('0x54')]['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x12fc15,null))[_0xf326('0x20')](function(_0xb8b431){if(_0xb8b431){_0x2b6585=_0xb8b431;_0x43685f['model']=_[_0xf326('0x55')](db[_0xf326('0x99')][_0xf326('0x64')]);_0x43685f[_0xf326('0x40')]=_[_0xf326('0x55')](_0x392052['query']);_0x43685f['filters']=_[_0xf326('0x42')](_0x43685f[_0xf326('0x3f')],_0x43685f['query']);_0x3b455d[_0xf326('0x43')]=_[_0xf326('0x42')](_0x43685f[_0xf326('0x3f')],qs[_0xf326('0x44')](_0x392052['query'][_0xf326('0x44')]));_0x3b455d[_0xf326('0x43')]=_0x3b455d['attributes'][_0xf326('0x45')]?_0x3b455d[_0xf326('0x43')]:_0x43685f[_0xf326('0x3f')];_0x3b455d[_0xf326('0x66')]=qs[_0xf326('0x47')](_0x392052[_0xf326('0x40')][_0xf326('0x47')]);_0x3b455d[_0xf326('0x48')]=qs[_0xf326('0x41')](_[_0xf326('0x67')](_0x392052[_0xf326('0x40')],_0x43685f['filters']));if(_0x392052[_0xf326('0x40')][_0xf326('0x4c')]){_0x3b455d[_0xf326('0x48')]=_[_0xf326('0x49')](_0x3b455d[_0xf326('0x48')],{'$or':_[_0xf326('0x3c')](_0x3b455d[_0xf326('0x43')],function(_0x2e5e53){var _0x58b007={};_0x58b007[_0x2e5e53]={'$like':'%'+_0x392052[_0xf326('0x40')][_0xf326('0x4c')]+'%'};return _0x58b007;})});}_0x3b455d=_[_0xf326('0x49')]({},_0x3b455d,_0x392052[_0xf326('0x4d')]);return _0x2b6585['getAgents'](_0x3b455d);}})[_0xf326('0x20')](function(_0x24fd01){if(_0x24fd01){_0x3d77af=_0x24fd01[_0xf326('0x45')];if(!_0x392052['query'][_0xf326('0x65')](_0xf326('0x46'))){_0x3b455d['limit']=qs['limit'](_0x392052[_0xf326('0x40')][_0xf326('0x2c')]);_0x3b455d[_0xf326('0x2b')]=qs[_0xf326('0x2b')](_0x392052[_0xf326('0x40')][_0xf326('0x2b')]);}return _0x2b6585[_0xf326('0xb7')](_0x3b455d);}})[_0xf326('0x20')](function(_0xdef17){if(_0xdef17){return _0xdef17?{'count':_0x3d77af,'rows':_0xdef17}:null;}})[_0xf326('0x20')](respondWithResult(_0x12fc15,null))[_0xf326('0x53')](handleError(_0x12fc15,null));};exports[_0xf326('0x39')]=function(_0x3e2067,_0x4a0a44,_0x4f2807){var _0x3121a,_0x49605d,_0x4ab9c0;if(_['isNil'](_0x3e2067[_0xf326('0x58')][_0xf326('0x58')])||_0x3e2067['body'][_0xf326('0x58')]===''){throw new db[(_0xf326('0x6f'))][(_0xf326('0x70'))](_0xf326('0x78'));}if(_[_0xf326('0x76')](_0x3e2067[_0xf326('0x58')]['to'])){}_0x3121a=_0x3e2067['body']['to'];return db[_0xf326('0x3d')][_0xf326('0x62')]({'where':{'id':_0x3e2067['params']['id']}})[_0xf326('0x20')](handleEntityNotFound(_0x4a0a44,null))[_0xf326('0x20')](function(_0x3cfea3){if(_0x3cfea3){return db['OpenchannelAccount'][_0xf326('0x56')]({'where':{'id':_0x3cfea3['id']},'include':[{'model':db[_0xf326('0x7d')],'as':_0xf326('0x7e'),'include':[{'model':db[_0xf326('0x6e')],'as':_0xf326('0x7f'),'where':{[_0x3cfea3['mapKey']]:_0x3121a},'limit':0x1,'order':[[_0xf326('0x74'),_0xf326('0x80')]]}]}]})['then'](handleEntityNotFound(_0x4a0a44,null))[_0xf326('0x20')](function(_0x1e4cae){if(_0x1e4cae&&_0x1e4cae[_0xf326('0x7e')]){_0x49605d=_0x1e4cae['get']({'plain':!![]});if(_0x49605d['List']&&_0x49605d[_0xf326('0x7e')][_0xf326('0x7f')]['length']){return _0x49605d[_0xf326('0x7e')][_0xf326('0x7f')][0x0];}return db[_0xf326('0x6e')][_0xf326('0x57')](_['defaults'](_0x3e2067['body'],{'firstName':_0x3121a,[_0x1e4cae[_0xf326('0x79')]]:_0x3121a,'phone':_0x3121a,'ListId':_0x49605d[_0xf326('0x88')]}));}})[_0xf326('0x20')](handleEntityNotFound(_0x4a0a44,null))[_0xf326('0x20')](function(_0x1fbd62){if(_0x1fbd62){_0x4ab9c0=_0x1fbd62;return db[_0xf326('0x8c')][_0xf326('0x56')]({'where':{'ContactId':_0x4ab9c0['id'],'closed':![],'OpenchannelAccountId':_0x49605d['id']}})[_0xf326('0x20')](function(_0x591880){if(_0x591880){return[_0x591880,![]];}return db['OpenchannelInteraction']['create']({'UserId':_0x3e2067[_0xf326('0x5a')]['id'],'ContactId':_0x4ab9c0['id'],'OpenchannelAccountId':_0x49605d['id'],'lastMsgDirection':_0xf326('0xb8'),'Messages':[_[_0xf326('0x49')](_0x3e2067['body'],{'read':![],'body':_0x3e2067[_0xf326('0x58')][_0xf326('0x58')],'OpenchannelAccountId':_0x49605d['id'],'UserId':_0x3e2067[_0xf326('0x5a')]['id'],'ContactId':_0x4ab9c0['id']})]},{'include':[{'model':db[_0xf326('0x96')],'as':'Messages'}]})['then'](function(_0x36dca0){return[_0x36dca0,!![]];});});}})[_0xf326('0x8f')](function(_0x49e8d6,_0x517f5e){if(_0x517f5e){return _0x49e8d6;}return db[_0xf326('0x96')][_0xf326('0x57')](_[_0xf326('0x49')](_0x3e2067[_0xf326('0x58')],{'read':![],'body':_0x3e2067[_0xf326('0x58')][_0xf326('0x58')],'OpenchannelAccountId':_0x49605d['id'],'OpenchannelInteractionId':_0x49e8d6['id'],'UserId':_0x3e2067['user']['id'],'ContactId':_0x4ab9c0['id']}))[_0xf326('0x20')](function(_0x84e8ad){_0x49e8d6['dataValues']['Messages']=[];_0x49e8d6[_0xf326('0xb9')][_0xf326('0xba')][_0xf326('0xbb')](_0x84e8ad[_0xf326('0xb9')]);return _0x49e8d6;});});}})[_0xf326('0x20')](respondWithResult(_0x4a0a44,null))[_0xf326('0x53')](handleError(_0x4a0a44,null));};
\ No newline at end of file
+var _0x1d7b=['dataValues','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','sox','lodash','crypto','desk.js','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelAccount.socket','register','jayson/promise','client','http','request','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','end','status','json','count','offset','limit','Content-Range','apply','reject','save','update','then','destroy','get','OpenchannelAccounts','UserProfileResource','name','send','Pause','mandatoryDispositionPause','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','OpenchannelAccount','includeAll','include','findAll','rows','catch','show','find','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','addDisposition','OpenchannelAccountId','Disposition','getDispositions','findOne','pick','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','options','removeAnswers','notify','openchannel','CmContact','Sequelize','ValidationError','difference','CompanyId','ListId','isNil','from','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','CmList','List','Contacts','updatedAt','DESC','OpenchannelApplication','Applications','applications','list','priority','asc','account','contact','lastName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','firstName','messageId','interaction','created','autoclose','close','*,*,*,*','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','addApplications','transaction','bulkCreate','getApplications','Contact','Owner','fullname','internal','Tag','color','tag','addAgents','emit','userOpenchannelAccount:save','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','body\x20is\x20mandatory\x20and\x20not\x20empty','OpenchannelMessage','Messages'];(function(_0x53be08,_0x4b4609){var _0xe0a29c=function(_0x4b5095){while(--_0x4b5095){_0x53be08['push'](_0x53be08['shift']());}};_0xe0a29c(++_0x4b4609);}(_0x1d7b,0xb9));var _0xb1d7=function(_0x8f45e5,_0x4e1695){_0x8f45e5=_0x8f45e5-0x0;var _0x57c49e=_0x1d7b[_0x8f45e5];return _0x57c49e;};'use strict';var pdf=require(_0xb1d7('0x0'));var emlformat=require(_0xb1d7('0x1'));var rimraf=require(_0xb1d7('0x2'));var zipdir=require(_0xb1d7('0x3'));var jsonpatch=require(_0xb1d7('0x4'));var rp=require(_0xb1d7('0x5'));var moment=require(_0xb1d7('0x6'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xb1d7('0x7'));var path=require(_0xb1d7('0x8'));var sox=require(_0xb1d7('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xb1d7('0xa'));var squel=require('squel');var crypto=require(_0xb1d7('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xb1d7('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xb1d7('0xd'));var qs=require(_0xb1d7('0xe'));var as=require(_0xb1d7('0xf'));var hardwareService=require(_0xb1d7('0x10'));var logger=require(_0xb1d7('0x11'))(_0xb1d7('0x12'));var utils=require('../../config/utils');var config=require(_0xb1d7('0x13'));var licenseUtil=require(_0xb1d7('0x14'));var db=require(_0xb1d7('0x15'))['db'];config[_0xb1d7('0x16')]=_[_0xb1d7('0x17')](config[_0xb1d7('0x16')],{'host':_0xb1d7('0x18'),'port':0x18eb});var socket=require(_0xb1d7('0x19'))(new Redis(config['redis']));require(_0xb1d7('0x1a'))[_0xb1d7('0x1b')](socket);var jayson=require(_0xb1d7('0x1c'));var client=jayson[_0xb1d7('0x1d')][_0xb1d7('0x1e')]({'port':0x232c});var client9002=jayson[_0xb1d7('0x1d')]['http']({'port':0x232a});function respondWithRpcPromise(_0x458350,_0x2e2bdc,_0x368de9,_0x28068c){return new BPromise(function(_0x3cd53c,_0xad2b82){var _0x354440=_0x28068c||client;return _0x354440[_0xb1d7('0x1f')](_0x458350,_0x368de9)['then'](function(_0x17cce2){logger['info'](_0xb1d7('0x20'),_0x2e2bdc,_0xb1d7('0x21'));logger[_0xb1d7('0x22')](_0xb1d7('0x23'),_0x2e2bdc,'request\x20sent',JSON[_0xb1d7('0x24')](_0x17cce2));if(_0x17cce2[_0xb1d7('0x25')]){if(_0x17cce2[_0xb1d7('0x25')][_0xb1d7('0x26')]===0x1f4){logger[_0xb1d7('0x25')](_0xb1d7('0x20'),_0x2e2bdc,_0x17cce2[_0xb1d7('0x25')][_0xb1d7('0x27')]);return _0xad2b82(_0x17cce2[_0xb1d7('0x25')]['message']);}logger[_0xb1d7('0x25')](_0xb1d7('0x20'),_0x2e2bdc,_0x17cce2[_0xb1d7('0x25')][_0xb1d7('0x27')]);return _0x3cd53c(_0x17cce2[_0xb1d7('0x25')][_0xb1d7('0x27')]);}else{logger[_0xb1d7('0x28')]('OpenchannelAccount,\x20%s,\x20%s',_0x2e2bdc,'request\x20sent');_0x3cd53c(_0x17cce2['result'][_0xb1d7('0x27')]);}})['catch'](function(_0x2689f4){logger[_0xb1d7('0x25')]('OpenchannelAccount,\x20%s,\x20%s',_0x2e2bdc,_0x2689f4);_0xad2b82(_0x2689f4);});});}function respondWithStatusCode(_0x1a6168,_0x526cd4){_0x526cd4=_0x526cd4||0xcc;return function(_0xb5cc7b){if(_0xb5cc7b){return _0x1a6168['sendStatus'](_0x526cd4);}return _0x1a6168['status'](_0x526cd4)[_0xb1d7('0x29')]();};}function respondWithResult(_0x11dc04,_0x145dd7){_0x145dd7=_0x145dd7||0xc8;return function(_0x57e8f2){if(_0x57e8f2){return _0x11dc04[_0xb1d7('0x2a')](_0x145dd7)[_0xb1d7('0x2b')](_0x57e8f2);}};}function respondWithFilteredResult(_0x9b9d7,_0x57768f){return function(_0x389e81){if(_0x389e81){var _0x1941be=_0x389e81[_0xb1d7('0x2c')],_0x28508f=_0x57768f[_0xb1d7('0x2d')],_0x423a68=_0x57768f[_0xb1d7('0x2d')]+_0x57768f[_0xb1d7('0x2e')],_0x1cf760;if(_0x423a68>=_0x1941be){_0x423a68=_0x1941be;_0x1cf760=0xc8;}else{_0x1cf760=0xce;}_0x9b9d7[_0xb1d7('0x2a')](_0x1cf760);return _0x9b9d7['set'](_0xb1d7('0x2f'),_0x28508f+'-'+_0x423a68+'/'+_0x1941be)['json'](_0x389e81);}return null;};}function patchUpdates(_0x2bd3cb){return function(_0x1101a5){try{jsonpatch[_0xb1d7('0x30')](_0x1101a5,_0x2bd3cb,!![]);}catch(_0x4a8254){return BPromise[_0xb1d7('0x31')](_0x4a8254);}return _0x1101a5[_0xb1d7('0x32')]();};}function saveUpdates(_0x53eec2,_0x4955a3){return function(_0x38d9e3){if(_0x38d9e3){return _0x38d9e3[_0xb1d7('0x33')](_0x53eec2)[_0xb1d7('0x34')](function(_0x5c81ae){return _0x5c81ae;});}return null;};}function removeEntity(_0x540e60,_0x5c4076){return function(_0xc54708){if(_0xc54708){return _0xc54708[_0xb1d7('0x35')]()['then'](function(){var _0x1e231b=_0xc54708[_0xb1d7('0x36')]({'plain':!![]});var _0x4bd02f=_0xb1d7('0x37');return db[_0xb1d7('0x38')][_0xb1d7('0x35')]({'where':{'type':_0x4bd02f,'resourceId':_0x1e231b['id']}})[_0xb1d7('0x34')](function(){return _0xc54708;});})[_0xb1d7('0x34')](function(){_0x540e60['status'](0xcc)[_0xb1d7('0x29')]();});}};}function handleEntityNotFound(_0x341d74,_0x566acd){return function(_0x2d14f8){if(!_0x2d14f8){_0x341d74['sendStatus'](0x194);}return _0x2d14f8;};}function handleError(_0x7e7c57,_0x4d1e0b){_0x4d1e0b=_0x4d1e0b||0x1f4;return function(_0x1acf9e){logger['error'](_0x1acf9e['stack']);if(_0x1acf9e[_0xb1d7('0x39')]){delete _0x1acf9e[_0xb1d7('0x39')];}_0x7e7c57[_0xb1d7('0x2a')](_0x4d1e0b)[_0xb1d7('0x3a')](_0x1acf9e);};}exports['index']=function(_0x39ce8c,_0x6e9f50){var _0x2f2ead={'include':[{'model':db[_0xb1d7('0x3b')],'as':_0xb1d7('0x3c')}]},_0x8ca49b={},_0xff4ff3={'count':0x0,'rows':[]};var _0x3adef9=_[_0xb1d7('0x3d')](db['OpenchannelAccount'][_0xb1d7('0x3e')],function(_0x18ad98){return{'name':_0x18ad98[_0xb1d7('0x3f')],'type':_0x18ad98[_0xb1d7('0x40')][_0xb1d7('0x41')]};});_0x8ca49b[_0xb1d7('0x42')]=_[_0xb1d7('0x3d')](_0x3adef9,'name');_0x8ca49b[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x39ce8c[_0xb1d7('0x43')]);_0x8ca49b[_0xb1d7('0x45')]=_[_0xb1d7('0x46')](_0x8ca49b[_0xb1d7('0x42')],_0x8ca49b['query']);_0x2f2ead[_0xb1d7('0x47')]=_[_0xb1d7('0x46')](_0x8ca49b[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x2f2ead[_0xb1d7('0x47')]=_0x2f2ead['attributes'][_0xb1d7('0x49')]?_0x2f2ead[_0xb1d7('0x47')]:_0x8ca49b[_0xb1d7('0x42')];if(!_0x39ce8c['query'][_0xb1d7('0x4a')](_0xb1d7('0x4b'))){_0x2f2ead[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x2e')]);_0x2f2ead['offset']=qs[_0xb1d7('0x2d')](_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x2d')]);}_0x2f2ead[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x2f2ead[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_['pick'](_0x39ce8c[_0xb1d7('0x43')],_0x8ca49b[_0xb1d7('0x45')]),_0x3adef9);if(_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x4f')]){_0x2f2ead[_0xb1d7('0x4e')]=_[_0xb1d7('0x50')](_0x2f2ead[_0xb1d7('0x4e')],{'$or':_[_0xb1d7('0x3d')](_0x3adef9,function(_0x46caa5){if(_0x46caa5['type']!==_0xb1d7('0x51')){var _0xb37874={};_0xb37874[_0x46caa5[_0xb1d7('0x39')]]={'$like':'%'+_0x39ce8c['query']['filter']+'%'};return _0xb37874;}})});}_0x2f2ead=_['merge']({},_0x2f2ead,_0x39ce8c['options']);var _0x26b902={'where':_0x2f2ead[_0xb1d7('0x4e')]};return db[_0xb1d7('0x52')][_0xb1d7('0x2c')](_0x26b902)[_0xb1d7('0x34')](function(_0x4dba54){_0xff4ff3[_0xb1d7('0x2c')]=_0x4dba54;if(_0x39ce8c[_0xb1d7('0x43')][_0xb1d7('0x53')]){_0x2f2ead[_0xb1d7('0x54')]=[{'all':!![]}];}return db[_0xb1d7('0x52')][_0xb1d7('0x55')](_0x2f2ead);})[_0xb1d7('0x34')](function(_0x569710){_0xff4ff3[_0xb1d7('0x56')]=_0x569710;return _0xff4ff3;})[_0xb1d7('0x34')](respondWithFilteredResult(_0x6e9f50,_0x2f2ead))[_0xb1d7('0x57')](handleError(_0x6e9f50,null));};exports[_0xb1d7('0x58')]=function(_0x397d2a,_0x2ed495){var _0x4a7b23={'raw':![],'where':{'id':_0x397d2a['params']['id']},'include':[{'model':db[_0xb1d7('0x3b')],'as':_0xb1d7('0x3c')}]},_0x586814={};_0x586814['model']=_[_0xb1d7('0x44')](db[_0xb1d7('0x52')][_0xb1d7('0x3e')]);_0x586814[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x397d2a['query']);_0x586814['filters']=_[_0xb1d7('0x46')](_0x586814[_0xb1d7('0x42')],_0x586814[_0xb1d7('0x43')]);_0x4a7b23['attributes']=_['intersection'](_0x586814[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x397d2a[_0xb1d7('0x43')]['fields']));_0x4a7b23[_0xb1d7('0x47')]=_0x4a7b23[_0xb1d7('0x47')]['length']?_0x4a7b23[_0xb1d7('0x47')]:_0x586814[_0xb1d7('0x42')];if(_0x397d2a[_0xb1d7('0x43')]['includeAll']){_0x4a7b23[_0xb1d7('0x54')]=[{'all':!![]}];}_0x4a7b23=_[_0xb1d7('0x50')]({},_0x4a7b23,_0x397d2a['options']);return db['OpenchannelAccount'][_0xb1d7('0x59')](_0x4a7b23)[_0xb1d7('0x34')](handleEntityNotFound(_0x2ed495,null))[_0xb1d7('0x34')](respondWithResult(_0x2ed495,null))[_0xb1d7('0x57')](handleError(_0x2ed495,null));};exports['create']=function(_0x4ee3b3,_0x3700d5){return db[_0xb1d7('0x52')]['create'](_0x4ee3b3['body'],{})[_0xb1d7('0x34')](function(_0x123689){var _0x307965=_0x4ee3b3[_0xb1d7('0x5a')][_0xb1d7('0x36')]({'plain':!![]});if(!_0x307965)throw new Error(_0xb1d7('0x5b'));if(_0x307965[_0xb1d7('0x5c')]===_0xb1d7('0x5a')){var _0xf9cc07=_0x123689[_0xb1d7('0x36')]({'plain':!![]});var _0x44b52e=_0xb1d7('0x37');return db[_0xb1d7('0x5d')][_0xb1d7('0x59')]({'where':{'name':_0x44b52e,'userProfileId':_0x307965['userProfileId']},'raw':!![]})[_0xb1d7('0x34')](function(_0x12c8f5){if(_0x12c8f5&&_0x12c8f5[_0xb1d7('0x5e')]===0x0){return db[_0xb1d7('0x38')][_0xb1d7('0x5f')]({'name':_0xf9cc07[_0xb1d7('0x39')],'resourceId':_0xf9cc07['id'],'type':_0x12c8f5[_0xb1d7('0x39')],'sectionId':_0x12c8f5['id']},{})['then'](function(){return _0x123689;});}else{return _0x123689;}})[_0xb1d7('0x57')](function(_0x50921d){logger[_0xb1d7('0x25')](_0xb1d7('0x60'),_0x50921d);throw _0x50921d;});}return _0x123689;})['then'](respondWithResult(_0x3700d5,0xc9))[_0xb1d7('0x57')](handleError(_0x3700d5,null));};exports[_0xb1d7('0x33')]=function(_0x4b6b62,_0x573af7){if(_0x4b6b62[_0xb1d7('0x61')]['id']){delete _0x4b6b62[_0xb1d7('0x61')]['id'];}return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x4b6b62[_0xb1d7('0x62')]['id']},'include':[{'model':db[_0xb1d7('0x3b')],'as':_0xb1d7('0x3c')}]})[_0xb1d7('0x34')](handleEntityNotFound(_0x573af7,null))[_0xb1d7('0x34')](saveUpdates(_0x4b6b62[_0xb1d7('0x61')],null))['then'](respondWithResult(_0x573af7,null))[_0xb1d7('0x57')](handleError(_0x573af7,null));};exports['destroy']=function(_0x44c1b3,_0x56159f){return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x44c1b3[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x56159f,null))[_0xb1d7('0x34')](removeEntity(_0x56159f,null))['catch'](handleError(_0x56159f,null));};exports[_0xb1d7('0x63')]=function(_0x32a2ed,_0xf559b4){return db[_0xb1d7('0x52')][_0xb1d7('0x63')]()[_0xb1d7('0x34')](respondWithResult(_0xf559b4,null))[_0xb1d7('0x57')](handleError(_0xf559b4,null));};exports[_0xb1d7('0x64')]=function(_0x144105,_0x327c00,_0x1a0f28){if(_0x144105['body']['id']){delete _0x144105[_0xb1d7('0x61')]['id'];}return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x144105[_0xb1d7('0x62')]['id']}})['then'](handleEntityNotFound(_0x327c00,null))[_0xb1d7('0x34')](function(_0x64c455){if(_0x64c455){_0x144105[_0xb1d7('0x61')][_0xb1d7('0x65')]=_0x64c455['id'];return db[_0xb1d7('0x66')]['create'](_0x144105[_0xb1d7('0x61')]);}})[_0xb1d7('0x34')](respondWithResult(_0x327c00,null))[_0xb1d7('0x57')](handleError(_0x327c00,null));};exports[_0xb1d7('0x67')]=function(_0x443047,_0x2fd556,_0x34f5a5){var _0x555a85={'raw':![],'where':{}};var _0x3c7470={};var _0x258066={'count':0x0,'rows':[]};return db[_0xb1d7('0x52')][_0xb1d7('0x68')]({'where':{'id':_0x443047[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x2fd556,null))[_0xb1d7('0x34')](function(_0x3ba299){if(_0x3ba299){_0x3c7470['model']=_[_0xb1d7('0x44')](db[_0xb1d7('0x66')]['rawAttributes']);_0x3c7470['query']=_[_0xb1d7('0x44')](_0x443047[_0xb1d7('0x43')]);_0x3c7470['filters']=_[_0xb1d7('0x46')](_0x3c7470[_0xb1d7('0x42')],_0x3c7470[_0xb1d7('0x43')]);_0x555a85[_0xb1d7('0x47')]=_['intersection'](_0x3c7470[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x443047[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x555a85[_0xb1d7('0x47')]=_0x555a85['attributes'][_0xb1d7('0x49')]?_0x555a85[_0xb1d7('0x47')]:_0x3c7470['model'];if(!_0x443047[_0xb1d7('0x43')][_0xb1d7('0x4a')](_0xb1d7('0x4b'))){_0x555a85[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x443047[_0xb1d7('0x43')][_0xb1d7('0x2e')]);_0x555a85[_0xb1d7('0x2d')]=qs[_0xb1d7('0x2d')](_0x443047['query'][_0xb1d7('0x2d')]);}_0x555a85[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x443047[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x555a85[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_[_0xb1d7('0x69')](_0x443047[_0xb1d7('0x43')],_0x3c7470[_0xb1d7('0x45')]));_0x555a85[_0xb1d7('0x4e')][_0xb1d7('0x65')]=_0x3ba299['id'];if(_0x443047[_0xb1d7('0x43')][_0xb1d7('0x4f')]){_0x555a85['where']=_[_0xb1d7('0x50')](_0x555a85[_0xb1d7('0x4e')],{'$or':_[_0xb1d7('0x3d')](_0x555a85[_0xb1d7('0x47')],function(_0x5940cd){var _0xd900aa={};_0xd900aa[_0x5940cd]={'$like':'%'+_0x443047[_0xb1d7('0x43')]['filter']+'%'};return _0xd900aa;})});}_0x555a85=_[_0xb1d7('0x50')]({},_0x555a85,_0x443047['options']);return db[_0xb1d7('0x66')][_0xb1d7('0x2c')]({'where':_0x555a85['where']})[_0xb1d7('0x34')](function(_0x1c11d3){_0x258066[_0xb1d7('0x2c')]=_0x1c11d3;if(_0x443047[_0xb1d7('0x43')][_0xb1d7('0x53')]){_0x555a85[_0xb1d7('0x54')]=[{'all':!![]}];}return db[_0xb1d7('0x66')][_0xb1d7('0x55')](_0x555a85);})[_0xb1d7('0x34')](function(_0xa9dbd){_0x258066[_0xb1d7('0x56')]=_0xa9dbd;return _0x258066;});}})[_0xb1d7('0x34')](respondWithFilteredResult(_0x2fd556,_0x555a85))[_0xb1d7('0x57')](handleError(_0x2fd556,null));};exports[_0xb1d7('0x6a')]=function(_0x348a7c,_0x4172af,_0x41cd15){return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x348a7c[_0xb1d7('0x62')]['id']}})['then'](handleEntityNotFound(_0x4172af,null))['then'](function(_0x1487da){if(_0x1487da){return _0x1487da[_0xb1d7('0x6a')](_0x348a7c[_0xb1d7('0x43')][_0xb1d7('0x6b')]);}})[_0xb1d7('0x34')](respondWithStatusCode(_0x4172af,null))[_0xb1d7('0x57')](handleError(_0x4172af,null));};exports[_0xb1d7('0x6c')]=function(_0x8f95da,_0x25e774,_0x187e60){if(_0x8f95da[_0xb1d7('0x61')]['id']){delete _0x8f95da['body']['id'];}return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x8f95da['params']['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x25e774,null))[_0xb1d7('0x34')](function(_0x3892c7){if(_0x3892c7){_0x8f95da[_0xb1d7('0x61')][_0xb1d7('0x65')]=_0x3892c7['id'];return db[_0xb1d7('0x6d')][_0xb1d7('0x5f')](_0x8f95da[_0xb1d7('0x61')]);}})['then'](respondWithResult(_0x25e774,null))[_0xb1d7('0x57')](handleError(_0x25e774,null));};exports[_0xb1d7('0x6e')]=function(_0x5e2974,_0x5e3a83,_0x276431){var _0x2c19d7={'raw':![],'where':{}};var _0x3d72fd={};var _0x328c24={'count':0x0,'rows':[]};return db[_0xb1d7('0x52')][_0xb1d7('0x68')]({'where':{'id':_0x5e2974[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x5e3a83,null))[_0xb1d7('0x34')](function(_0x533bac){if(_0x533bac){_0x3d72fd[_0xb1d7('0x42')]=_[_0xb1d7('0x44')](db['CannedAnswer'][_0xb1d7('0x3e')]);_0x3d72fd[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x5e2974[_0xb1d7('0x43')]);_0x3d72fd['filters']=_[_0xb1d7('0x46')](_0x3d72fd[_0xb1d7('0x42')],_0x3d72fd[_0xb1d7('0x43')]);_0x2c19d7[_0xb1d7('0x47')]=_[_0xb1d7('0x46')](_0x3d72fd[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x2c19d7[_0xb1d7('0x47')]=_0x2c19d7[_0xb1d7('0x47')][_0xb1d7('0x49')]?_0x2c19d7[_0xb1d7('0x47')]:_0x3d72fd[_0xb1d7('0x42')];if(!_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x4a')](_0xb1d7('0x4b'))){_0x2c19d7[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x2e')]);_0x2c19d7[_0xb1d7('0x2d')]=qs[_0xb1d7('0x2d')](_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x2d')]);}_0x2c19d7[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x2c19d7[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_['pick'](_0x5e2974['query'],_0x3d72fd[_0xb1d7('0x45')]));_0x2c19d7[_0xb1d7('0x4e')][_0xb1d7('0x65')]=_0x533bac['id'];if(_0x5e2974[_0xb1d7('0x43')]['filter']){_0x2c19d7['where']=_['merge'](_0x2c19d7[_0xb1d7('0x4e')],{'$or':_['map'](_0x2c19d7[_0xb1d7('0x47')],function(_0xa743a5){var _0x1a69c4={};_0x1a69c4[_0xa743a5]={'$like':'%'+_0x5e2974[_0xb1d7('0x43')]['filter']+'%'};return _0x1a69c4;})});}_0x2c19d7=_[_0xb1d7('0x50')]({},_0x2c19d7,_0x5e2974[_0xb1d7('0x6f')]);return db[_0xb1d7('0x6d')][_0xb1d7('0x2c')]({'where':_0x2c19d7[_0xb1d7('0x4e')]})[_0xb1d7('0x34')](function(_0x5868cc){_0x328c24[_0xb1d7('0x2c')]=_0x5868cc;if(_0x5e2974[_0xb1d7('0x43')][_0xb1d7('0x53')]){_0x2c19d7[_0xb1d7('0x54')]=[{'all':!![]}];}return db[_0xb1d7('0x6d')][_0xb1d7('0x55')](_0x2c19d7);})[_0xb1d7('0x34')](function(_0x2689a9){_0x328c24[_0xb1d7('0x56')]=_0x2689a9;return _0x328c24;});}})['then'](respondWithFilteredResult(_0x5e3a83,_0x2c19d7))[_0xb1d7('0x57')](handleError(_0x5e3a83,null));};exports[_0xb1d7('0x70')]=function(_0x1e4b3f,_0x2a8817,_0x93c8df){return db['OpenchannelAccount'][_0xb1d7('0x59')]({'where':{'id':_0x1e4b3f[_0xb1d7('0x62')]['id']}})['then'](handleEntityNotFound(_0x2a8817,null))[_0xb1d7('0x34')](function(_0x51e3f4){if(_0x51e3f4){return _0x51e3f4['removeAnswers'](_0x1e4b3f[_0xb1d7('0x43')]['ids']);}})[_0xb1d7('0x34')](respondWithStatusCode(_0x2a8817,null))[_0xb1d7('0x57')](handleError(_0x2a8817,null));};exports[_0xb1d7('0x71')]=function(_0x517121,_0x249300,_0x411f3d){var _0x14a111={'body':_0x517121[_0xb1d7('0x61')],'channel':_0xb1d7('0x72')};var _0x19e86e=[];var _0x3cb71d=[];var _0x33ddc0={};var _0x293c60=![];return db[_0xb1d7('0x73')][_0xb1d7('0x63')]()[_0xb1d7('0x34')](function(_0x8b6a64){if(!_0x8b6a64){throw new db[(_0xb1d7('0x74'))][(_0xb1d7('0x75'))]('no\x20available\x20attributes');}_0x19e86e=_['difference'](_[_0xb1d7('0x44')](_0x8b6a64),['createdAt','updatedAt']);_0x3cb71d=_[_0xb1d7('0x76')](_['keys'](_0x8b6a64),['createdAt','updatedAt',_0xb1d7('0x77'),_0xb1d7('0x78')]);if(_0x517121[_0xb1d7('0x61')]['id']){delete _0x517121[_0xb1d7('0x61')]['id'];}if(_[_0xb1d7('0x79')](_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7a')])){throw new db[(_0xb1d7('0x74'))][(_0xb1d7('0x75'))]('from\x20is\x20mandatory');}if(_[_0xb1d7('0x79')](_0x517121[_0xb1d7('0x61')]['body'])||_0x517121[_0xb1d7('0x61')][_0xb1d7('0x61')]===''){throw new db[(_0xb1d7('0x74'))][(_0xb1d7('0x75'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xb1d7('0x79')](_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7b')])){throw new db[(_0xb1d7('0x74'))][(_0xb1d7('0x75'))](_0xb1d7('0x7c')+_0x3cb71d);}if(!_[_0xb1d7('0x7d')](_0x3cb71d,_0x517121[_0xb1d7('0x61')]['mapKey'])){throw new db['Sequelize'][(_0xb1d7('0x75'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x3cb71d);}_0x33ddc0[_0x517121['body'][_0xb1d7('0x7b')]]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7a')];})[_0xb1d7('0x34')](function(){return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x517121['params']['id']},'include':[{'model':db[_0xb1d7('0x7e')],'as':_0xb1d7('0x7f'),'include':[{'model':db['CmContact'],'as':_0xb1d7('0x80'),'where':_0x33ddc0,'limit':0x1,'order':[[_0xb1d7('0x81'),_0xb1d7('0x82')]]}]},{'model':db[_0xb1d7('0x83')],'as':_0xb1d7('0x84')}]});})[_0xb1d7('0x34')](handleEntityNotFound(_0x249300,null))[_0xb1d7('0x34')](function(_0x48cf3f){if(_0x48cf3f&&_0x48cf3f[_0xb1d7('0x7f')]){_0x14a111['account']=_0x48cf3f;_0x14a111[_0xb1d7('0x85')]=_0x48cf3f[_0xb1d7('0x84')];_0x14a111[_0xb1d7('0x86')]=_0x48cf3f[_0xb1d7('0x7f')];_0x14a111['applications']=_['orderBy'](_0x14a111[_0xb1d7('0x85')],[_0xb1d7('0x87')],[_0xb1d7('0x88')]);if(_0x14a111[_0xb1d7('0x89')][_0xb1d7('0x84')]){delete _0x14a111['account'][_0xb1d7('0x84')];}if(_0x14a111[_0xb1d7('0x89')][_0xb1d7('0x7f')]&&_0x14a111[_0xb1d7('0x89')]['List'][_0xb1d7('0x80')]['length']){return _0x14a111['account']['List'][_0xb1d7('0x80')][0x0];}var _0x2c2784=_['defaults'](_0x517121[_0xb1d7('0x61')],{'firstName':_0x517121['body'][_0xb1d7('0x7a')],'ListId':_0x48cf3f[_0xb1d7('0x78')]});_0x2c2784[_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7b')]]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x7a')];return db[_0xb1d7('0x73')][_0xb1d7('0x5f')](_0x2c2784,{'fields':_0x19e86e,'raw':!![]});}})[_0xb1d7('0x34')](handleEntityNotFound(_0x249300,null))[_0xb1d7('0x34')](function(_0x478021){_0x14a111[_0xb1d7('0x8a')]=_0x478021;if(_0x478021){var _0x34bbe9={'ContactId':_0x478021['id'],'OpenchannelAccountId':_0x517121[_0xb1d7('0x62')]['id'],'from':(_0x478021['firstName']||'')+'\x20'+(_0x478021[_0xb1d7('0x8b')]||'')};var _0x505af0={'OpenchannelAccountId':_0x517121[_0xb1d7('0x62')]['id'],'closed':![]};if(_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8c')]){_0x505af0[_0xb1d7('0x8c')]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8c')];return db[_0xb1d7('0x8d')][_0xb1d7('0x59')]({'where':_0x505af0})[_0xb1d7('0x34')](function(_0x38ffdd){if(_0x38ffdd){return[_0x38ffdd,![]];}_0x34bbe9[_0xb1d7('0x8c')]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8c')];_0x34bbe9[_0xb1d7('0x8e')]=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8e')];return db[_0xb1d7('0x8d')][_0xb1d7('0x5f')](_0x34bbe9)[_0xb1d7('0x34')](function(_0x43ad06){return[_0x43ad06,!![]];});});}else{_0x505af0[_0xb1d7('0x8c')]=null;}_0x505af0[_0xb1d7('0x8f')]=_0x478021['id'];return db[_0xb1d7('0x8d')][_0xb1d7('0x59')]({'where':_0x505af0})['then'](function(_0x590d15){if(_0x590d15){return[_0x590d15,![]];}return db[_0xb1d7('0x8d')][_0xb1d7('0x5f')](_0x34bbe9)[_0xb1d7('0x34')](function(_0x4a01b7){return[_0x4a01b7,!![]];});});}})[_0xb1d7('0x90')](function(_0x39929a,_0x4252cd){if(_0x39929a){_0x293c60=_0x4252cd;if(!_0x4252cd){var _0x25db1d={'from':(_0x14a111['contact'][_0xb1d7('0x91')]||'')+'\x20'+(_0x14a111[_0xb1d7('0x8a')][_0xb1d7('0x8b')]||'')};if(_0x517121[_0xb1d7('0x61')][_0xb1d7('0x8c')]&&_0x517121['body'][_0xb1d7('0x92')]&&_0x517121[_0xb1d7('0x61')]['threadId']!=_0x517121[_0xb1d7('0x61')][_0xb1d7('0x92')]){_0x25db1d[_0xb1d7('0x8c')]=_0x517121['body']['messageId'];}return _0x39929a[_0xb1d7('0x33')](_0x25db1d);}else{return _0x39929a;}}})[_0xb1d7('0x34')](function(_0x47335f){_0x14a111[_0xb1d7('0x93')]=_0x47335f['get']({'plain':!![]});_0x14a111['interaction'][_0xb1d7('0x94')]=_0x293c60;if(_0x14a111['interaction'][_0xb1d7('0x94')]){if(_0x14a111[_0xb1d7('0x89')][_0xb1d7('0x95')]){_0x14a111[_0xb1d7('0x85')]['push']({'id':0x0,'priority':_0x14a111[_0xb1d7('0x85')][_0xb1d7('0x49')]+0x1,'app':_0xb1d7('0x96'),'appdata':'unmanaged','interval':_0xb1d7('0x97')});}}return db['OpenchannelMessage']['create']({'body':_0x517121[_0xb1d7('0x61')][_0xb1d7('0x61')],'OpenchannelAccountId':_0x517121[_0xb1d7('0x62')]['id'],'OpenchannelInteractionId':_0x47335f['id'],'direction':'in','ContactId':_0x14a111[_0xb1d7('0x8a')]['id'],'AttachmentId':_0x517121[_0xb1d7('0x61')][_0xb1d7('0x98')]});})[_0xb1d7('0x34')](function(_0x4c8219){_0x14a111['message']=_0x4c8219;if(_0x14a111['interaction'][_0xb1d7('0x99')]){return db[_0xb1d7('0x9a')]['find']({'attributes':['id',_0xb1d7('0x39')],'where':{'id':_0x14a111['interaction'][_0xb1d7('0x99')]}})['then'](function(_0x5941d0){if(_0x5941d0){_0x14a111[_0xb1d7('0x85')][_0xb1d7('0x9b')]({'id':0x0,'priority':0x0,'app':_0xb1d7('0x9c'),'appdata':_0x5941d0['name']+','+(_0x14a111[_0xb1d7('0x89')][_0xb1d7('0x9d')]||0xa),'interval':_0xb1d7('0x97')});_0x14a111[_0xb1d7('0x9e')]=![];}return respondWithRpcPromise(_0xb1d7('0x9f'),'startRouting',_0x14a111);});}return respondWithRpcPromise(_0xb1d7('0x9f'),_0xb1d7('0xa0'),_0x14a111);})['then'](function(_0x3482c1){respondWithRpcPromise(_0xb1d7('0xa1'),_0xb1d7('0xa1'),{'event':_0xb1d7('0x71'),'message':_0x3482c1},client9002);return _0x3482c1;})[_0xb1d7('0x34')](respondWithResult(_0x249300,null))[_0xb1d7('0x57')](handleError(_0x249300,null));};exports[_0xb1d7('0xa2')]=function(_0x253bca,_0x5624db,_0x3846a4){return db[_0xb1d7('0x52')][_0xb1d7('0x68')]({'where':{'id':_0x253bca[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x5624db,null))[_0xb1d7('0x34')](function(_0x4724ad){if(_0x4724ad){return db['sequelize'][_0xb1d7('0xa3')](function(_0x1821c5){return db['OpenchannelApplication'][_0xb1d7('0x35')]({'where':{'OpenchannelAccountId':_0x253bca[_0xb1d7('0x62')]['id']},'transaction':_0x1821c5})[_0xb1d7('0x34')](function(_0x5375c1){var _0x3c0ede=_[_0xb1d7('0x3d')](_0x253bca[_0xb1d7('0x61')],function(_0x4f2a76){_0x4f2a76[_0xb1d7('0x65')]=_0x253bca[_0xb1d7('0x62')]['id'];return _0x4f2a76;});return db['OpenchannelApplication'][_0xb1d7('0xa4')](_0x3c0ede,{'transaction':_0x1821c5});});})[_0xb1d7('0x34')](function(){return db[_0xb1d7('0x83')]['findAndCountAll']({'where':{'OpenchannelAccountId':_0x253bca[_0xb1d7('0x62')]['id']},'order':_0xb1d7('0x87')});});}})['then'](respondWithResult(_0x5624db,null))[_0xb1d7('0x57')](handleError(_0x5624db,null));};exports[_0xb1d7('0xa5')]=function(_0x31f843,_0x37e3ae,_0x47188d){var _0x589fff={};var _0x3b5fec={};var _0x274099;var _0x4e1ca2;return db['OpenchannelAccount'][_0xb1d7('0x68')]({'where':{'id':_0x31f843[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x37e3ae,null))['then'](function(_0x3e313f){if(_0x3e313f){_0x274099=_0x3e313f;_0x3b5fec[_0xb1d7('0x42')]=_[_0xb1d7('0x44')](db[_0xb1d7('0x83')][_0xb1d7('0x3e')]);_0x3b5fec[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x31f843['query']);_0x3b5fec['filters']=_[_0xb1d7('0x46')](_0x3b5fec['model'],_0x3b5fec[_0xb1d7('0x43')]);_0x589fff['attributes']=_['intersection'](_0x3b5fec[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x589fff[_0xb1d7('0x47')]=_0x589fff['attributes'][_0xb1d7('0x49')]?_0x589fff[_0xb1d7('0x47')]:_0x3b5fec[_0xb1d7('0x42')];_0x589fff['order']=qs[_0xb1d7('0x4d')](_0x31f843['query'][_0xb1d7('0x4d')]);_0x589fff[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_[_0xb1d7('0x69')](_0x31f843[_0xb1d7('0x43')],_0x3b5fec[_0xb1d7('0x45')]));if(_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x4f')]){_0x589fff['where']=_['merge'](_0x589fff[_0xb1d7('0x4e')],{'$or':_[_0xb1d7('0x3d')](_0x589fff[_0xb1d7('0x47')],function(_0x38c415){var _0x44dedc={};_0x44dedc[_0x38c415]={'$like':'%'+_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x4f')]+'%'};return _0x44dedc;})});}_0x589fff=_[_0xb1d7('0x50')]({},_0x589fff,_0x31f843['options']);return _0x274099[_0xb1d7('0xa5')](_0x589fff);}})[_0xb1d7('0x34')](function(_0x2075a0){if(_0x2075a0){_0x4e1ca2=_0x2075a0['length'];if(!_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x4a')]('nolimit')){_0x589fff[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x2e')]);_0x589fff['offset']=qs[_0xb1d7('0x2d')](_0x31f843[_0xb1d7('0x43')][_0xb1d7('0x2d')]);}return _0x274099[_0xb1d7('0xa5')](_0x589fff);}})['then'](function(_0x1f6be9){if(_0x1f6be9){return _0x1f6be9?{'count':_0x4e1ca2,'rows':_0x1f6be9}:null;}})[_0xb1d7('0x34')](respondWithResult(_0x37e3ae,null))['catch'](handleError(_0x37e3ae,null));};exports['getInteractions']=function(_0x32d0d5,_0x1c1826,_0x1c63e1){var _0x31eb39={'raw':![],'where':{}};var _0x592bdc={};var _0x2b753c={'count':0x0,'rows':[]};return db[_0xb1d7('0x52')][_0xb1d7('0x68')]({'where':{'id':_0x32d0d5[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x1c1826,null))[_0xb1d7('0x34')](function(_0x18931e){if(_0x18931e){_0x592bdc[_0xb1d7('0x42')]=_[_0xb1d7('0x44')](db[_0xb1d7('0x8d')][_0xb1d7('0x3e')]);_0x592bdc[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x32d0d5[_0xb1d7('0x43')]);_0x592bdc[_0xb1d7('0x45')]=_[_0xb1d7('0x46')](_0x592bdc[_0xb1d7('0x42')],_0x592bdc[_0xb1d7('0x43')]);_0x31eb39[_0xb1d7('0x47')]=_[_0xb1d7('0x46')](_0x592bdc[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x31eb39['attributes']=_0x31eb39['attributes'][_0xb1d7('0x49')]?_0x31eb39[_0xb1d7('0x47')]:_0x592bdc['model'];if(!_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x4a')](_0xb1d7('0x4b'))){_0x31eb39[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x32d0d5['query'][_0xb1d7('0x2e')]);_0x31eb39[_0xb1d7('0x2d')]=qs[_0xb1d7('0x2d')](_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x2d')]);}_0x31eb39[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x31eb39[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_[_0xb1d7('0x69')](_0x32d0d5[_0xb1d7('0x43')],_0x592bdc[_0xb1d7('0x45')]));_0x31eb39[_0xb1d7('0x4e')][_0xb1d7('0x65')]=_0x18931e['id'];if(_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x4f')]){_0x31eb39[_0xb1d7('0x4e')]=_[_0xb1d7('0x50')](_0x31eb39['where'],{'$or':_[_0xb1d7('0x3d')](_0x31eb39[_0xb1d7('0x47')],function(_0x49be96){var _0x50378d={};_0x50378d[_0x49be96]={'$like':'%'+_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0x4f')]+'%'};return _0x50378d;})});}_0x31eb39=_[_0xb1d7('0x50')]({},_0x31eb39,_0x32d0d5[_0xb1d7('0x6f')]);return db[_0xb1d7('0x8d')]['count']({'where':_0x31eb39[_0xb1d7('0x4e')]})[_0xb1d7('0x34')](function(_0x395b2e){_0x2b753c[_0xb1d7('0x2c')]=_0x395b2e;if(_0x32d0d5[_0xb1d7('0x43')]['includeAll']){_0x31eb39[_0xb1d7('0x54')]=[{'model':db[_0xb1d7('0x73')],'as':_0xb1d7('0xa6'),'required':![]},{'model':db[_0xb1d7('0x9a')],'as':_0xb1d7('0xa7'),'attributes':[_0xb1d7('0x39'),_0xb1d7('0xa8'),_0xb1d7('0xa9')],'required':![]},{'model':db[_0xb1d7('0xaa')],'as':'Tags','attributes':['id',_0xb1d7('0x39'),_0xb1d7('0xab')],'where':_0x32d0d5[_0xb1d7('0x43')]['tag']?{'id':_0x32d0d5[_0xb1d7('0x43')][_0xb1d7('0xac')]}:undefined,'required':_0x32d0d5[_0xb1d7('0x43')]['tag']?!![]:![]}];}return db[_0xb1d7('0x8d')][_0xb1d7('0x55')](_0x31eb39);})[_0xb1d7('0x34')](function(_0x4a93dd){_0x2b753c[_0xb1d7('0x56')]=_0x4a93dd;return _0x2b753c;});}})[_0xb1d7('0x34')](respondWithFilteredResult(_0x1c1826,_0x31eb39))['catch'](handleError(_0x1c1826,null));};exports[_0xb1d7('0xad')]=function(_0x566bb5,_0x4bef07,_0x57ad57){return db[_0xb1d7('0x52')][_0xb1d7('0x59')]({'where':{'id':_0x566bb5[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x4bef07,null))['then'](function(_0x5076c4){if(_0x5076c4){return _0x5076c4[_0xb1d7('0xad')](_0x566bb5['body'][_0xb1d7('0x6b')],_['omit'](_0x566bb5[_0xb1d7('0x61')],[_0xb1d7('0x6b'),'id'])||{})[_0xb1d7('0x90')](function(_0x502086){for(var _0x1e3043=0x0;_0x1e3043<_0x566bb5[_0xb1d7('0x61')][_0xb1d7('0x6b')][_0xb1d7('0x49')];_0x1e3043+=0x1){socket[_0xb1d7('0xae')](_0xb1d7('0xaf'),{'UserId':_0x566bb5['body'][_0xb1d7('0x6b')][_0x1e3043],'OpenchannelAccountId':_0x566bb5[_0xb1d7('0x62')]['id']});}return _0x502086;});}})[_0xb1d7('0x34')](respondWithResult(_0x4bef07,null))[_0xb1d7('0x57')](handleError(_0x4bef07,null));};exports[_0xb1d7('0xb0')]=function(_0x3f1daf,_0x3f0ce0,_0x8f1c73){return db['OpenchannelAccount'][_0xb1d7('0x59')]({'where':{'id':_0x3f1daf['params']['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x3f0ce0,null))[_0xb1d7('0x34')](function(_0x4e1414){if(_0x4e1414){return _0x4e1414[_0xb1d7('0xb0')](_0x3f1daf['query'][_0xb1d7('0x6b')])[_0xb1d7('0x34')](function(){if(_[_0xb1d7('0xb1')](_0x3f1daf[_0xb1d7('0x43')]['ids'])){for(var _0x3b2e71=0x0;_0x3b2e71<_0x3f1daf[_0xb1d7('0x43')][_0xb1d7('0x6b')]['length'];_0x3b2e71+=0x1){socket[_0xb1d7('0xae')](_0xb1d7('0xb2'),{'UserId':Number(_0x3f1daf['query'][_0xb1d7('0x6b')][_0x3b2e71]),'OpenchannelAccountId':Number(_0x3f1daf[_0xb1d7('0x62')]['id'])});}}else{socket[_0xb1d7('0xae')](_0xb1d7('0xb2'),{'UserId':Number(_0x3f1daf['query']['ids']),'OpenchannelAccountId':Number(_0x3f1daf['params']['id'])});}});}})[_0xb1d7('0x34')](respondWithStatusCode(_0x3f0ce0,null))[_0xb1d7('0x57')](handleError(_0x3f0ce0,null));};exports[_0xb1d7('0xb3')]=function(_0x4045b8,_0x1b2c29,_0x5d03d9){var _0x17dfb0={};var _0x31ef8d={};var _0x161835;var _0x191855;return db[_0xb1d7('0x52')]['findOne']({'where':{'id':_0x4045b8[_0xb1d7('0x62')]['id']}})['then'](handleEntityNotFound(_0x1b2c29,null))[_0xb1d7('0x34')](function(_0x229338){if(_0x229338){_0x161835=_0x229338;_0x31ef8d['model']=_[_0xb1d7('0x44')](db[_0xb1d7('0x9a')][_0xb1d7('0x3e')]);_0x31ef8d[_0xb1d7('0x43')]=_[_0xb1d7('0x44')](_0x4045b8[_0xb1d7('0x43')]);_0x31ef8d['filters']=_[_0xb1d7('0x46')](_0x31ef8d['model'],_0x31ef8d[_0xb1d7('0x43')]);_0x17dfb0['attributes']=_['intersection'](_0x31ef8d[_0xb1d7('0x42')],qs[_0xb1d7('0x48')](_0x4045b8[_0xb1d7('0x43')][_0xb1d7('0x48')]));_0x17dfb0[_0xb1d7('0x47')]=_0x17dfb0['attributes'][_0xb1d7('0x49')]?_0x17dfb0['attributes']:_0x31ef8d[_0xb1d7('0x42')];_0x17dfb0[_0xb1d7('0x4c')]=qs[_0xb1d7('0x4d')](_0x4045b8[_0xb1d7('0x43')][_0xb1d7('0x4d')]);_0x17dfb0[_0xb1d7('0x4e')]=qs[_0xb1d7('0x45')](_[_0xb1d7('0x69')](_0x4045b8['query'],_0x31ef8d['filters']));if(_0x4045b8['query'][_0xb1d7('0x4f')]){_0x17dfb0[_0xb1d7('0x4e')]=_[_0xb1d7('0x50')](_0x17dfb0['where'],{'$or':_[_0xb1d7('0x3d')](_0x17dfb0[_0xb1d7('0x47')],function(_0x5a005b){var _0x1db62b={};_0x1db62b[_0x5a005b]={'$like':'%'+_0x4045b8['query']['filter']+'%'};return _0x1db62b;})});}_0x17dfb0=_[_0xb1d7('0x50')]({},_0x17dfb0,_0x4045b8['options']);return _0x161835[_0xb1d7('0xb3')](_0x17dfb0);}})[_0xb1d7('0x34')](function(_0x4cb589){if(_0x4cb589){_0x191855=_0x4cb589['length'];if(!_0x4045b8[_0xb1d7('0x43')]['hasOwnProperty'](_0xb1d7('0x4b'))){_0x17dfb0[_0xb1d7('0x2e')]=qs[_0xb1d7('0x2e')](_0x4045b8['query']['limit']);_0x17dfb0['offset']=qs['offset'](_0x4045b8['query'][_0xb1d7('0x2d')]);}return _0x161835[_0xb1d7('0xb3')](_0x17dfb0);}})[_0xb1d7('0x34')](function(_0x8b37b2){if(_0x8b37b2){return _0x8b37b2?{'count':_0x191855,'rows':_0x8b37b2}:null;}})['then'](respondWithResult(_0x1b2c29,null))[_0xb1d7('0x57')](handleError(_0x1b2c29,null));};exports[_0xb1d7('0x3a')]=function(_0x4de1db,_0x590c12,_0x1dbc08){var _0x50ede4,_0x20ad58,_0x44877c;if(_['isNil'](_0x4de1db[_0xb1d7('0x61')]['body'])||_0x4de1db[_0xb1d7('0x61')][_0xb1d7('0x61')]===''){throw new db['Sequelize'][(_0xb1d7('0x75'))](_0xb1d7('0xb4'));}if(_[_0xb1d7('0x79')](_0x4de1db['body']['to'])){}_0x50ede4=_0x4de1db[_0xb1d7('0x61')]['to'];return db[_0xb1d7('0x52')]['findOne']({'where':{'id':_0x4de1db[_0xb1d7('0x62')]['id']}})[_0xb1d7('0x34')](handleEntityNotFound(_0x590c12,null))[_0xb1d7('0x34')](function(_0x58de2d){if(_0x58de2d){return db['OpenchannelAccount']['find']({'where':{'id':_0x58de2d['id']},'include':[{'model':db['CmList'],'as':_0xb1d7('0x7f'),'include':[{'model':db[_0xb1d7('0x73')],'as':_0xb1d7('0x80'),'where':{[_0x58de2d[_0xb1d7('0x7b')]]:_0x50ede4},'limit':0x1,'order':[[_0xb1d7('0x81'),_0xb1d7('0x82')]]}]}]})[_0xb1d7('0x34')](handleEntityNotFound(_0x590c12,null))[_0xb1d7('0x34')](function(_0x326b4a){if(_0x326b4a&&_0x326b4a[_0xb1d7('0x7f')]){_0x20ad58=_0x326b4a[_0xb1d7('0x36')]({'plain':!![]});if(_0x20ad58[_0xb1d7('0x7f')]&&_0x20ad58['List'][_0xb1d7('0x80')][_0xb1d7('0x49')]){return _0x20ad58['List'][_0xb1d7('0x80')][0x0];}return db[_0xb1d7('0x73')][_0xb1d7('0x5f')](_['defaults'](_0x4de1db[_0xb1d7('0x61')],{'firstName':_0x50ede4,[_0x326b4a['mapKey']]:_0x50ede4,'phone':_0x50ede4,'ListId':_0x20ad58['ListId']}));}})[_0xb1d7('0x34')](handleEntityNotFound(_0x590c12,null))[_0xb1d7('0x34')](function(_0x4501cf){if(_0x4501cf){_0x44877c=_0x4501cf;return db[_0xb1d7('0x8d')][_0xb1d7('0x59')]({'where':{'ContactId':_0x44877c['id'],'closed':![],'OpenchannelAccountId':_0x20ad58['id']}})[_0xb1d7('0x34')](function(_0x80785b){if(_0x80785b){return[_0x80785b,![]];}return db[_0xb1d7('0x8d')]['create']({'UserId':_0x4de1db['user']['id'],'ContactId':_0x44877c['id'],'OpenchannelAccountId':_0x20ad58['id'],'lastMsgDirection':'out','Messages':[_[_0xb1d7('0x50')](_0x4de1db[_0xb1d7('0x61')],{'read':![],'body':_0x4de1db['body'][_0xb1d7('0x61')],'OpenchannelAccountId':_0x20ad58['id'],'UserId':_0x4de1db['user']['id'],'ContactId':_0x44877c['id']})]},{'include':[{'model':db[_0xb1d7('0xb5')],'as':_0xb1d7('0xb6')}]})['then'](function(_0x480b22){return[_0x480b22,!![]];});});}})[_0xb1d7('0x90')](function(_0x3a816e,_0x5b5ba2){if(_0x5b5ba2){return _0x3a816e;}return db[_0xb1d7('0xb5')][_0xb1d7('0x5f')](_[_0xb1d7('0x50')](_0x4de1db[_0xb1d7('0x61')],{'read':![],'body':_0x4de1db[_0xb1d7('0x61')][_0xb1d7('0x61')],'OpenchannelAccountId':_0x20ad58['id'],'OpenchannelInteractionId':_0x3a816e['id'],'UserId':_0x4de1db[_0xb1d7('0x5a')]['id'],'ContactId':_0x44877c['id']}))[_0xb1d7('0x34')](function(_0x4d3907){_0x3a816e[_0xb1d7('0xb7')][_0xb1d7('0xb6')]=[];_0x3a816e[_0xb1d7('0xb7')]['Messages']['push'](_0x4d3907[_0xb1d7('0xb7')]);return _0x3a816e;});});}})[_0xb1d7('0x34')](respondWithResult(_0x590c12,null))[_0xb1d7('0x57')](handleError(_0x590c12,null));};
\ No newline at end of file