Built motion from commit (unavailable).|2.5.18
[motion2.git] / server / api / openchannelAccount / openchannelAccount.controller.js
index 447d3cd..0fb2848 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x187d=['debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','catch','sendStatus','status','end','json','count','offset','limit','apply','reject','save','update','destroy','OpenchannelAccounts','stack','name','send','index','map','OpenchannelAccount','rawAttributes','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','where','merge','VIRTUAL','filter','options','includeAll','findAll','rows','params','Pause','mandatoryDispositionPause','keys','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','OpenchannelAccountId','getDispositions','findOne','Disposition','include','CannedAnswer','getAnswers','removeAnswers','ids','openchannel','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','isNil','from','Sequelize','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','CmContact','OpenchannelApplication','Applications','account','applications','orderBy','priority','Contacts','firstName','lastName','threadId','externalUrl','OpenchannelInteraction','spread','contact','messageId','interaction','created','autoclose','close','unmanaged','OpenchannelMessage','AttachmentId','message','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','notify','addApplications','transaction','bulkCreate','findAndCountAll','getApplications','getInteractions','Owner','fullname','Tag','Tags','tag','omit','userOpenchannelAccount:save','removeAgents','isArray','emit','userOpenchannelAccount:remove','getAgents','body\x20is\x20mandatory\x20and\x20not\x20empty','DESC','Messages','dataValues','push','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelAccount.socket','jayson/promise','client','http','request','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent'];(function(_0x354b38,_0x743e4b){var _0x4ec694=function(_0x24cac8){while(--_0x24cac8){_0x354b38['push'](_0x354b38['shift']());}};_0x4ec694(++_0x743e4b);}(_0x187d,0x93));var _0xd187=function(_0x40ac5e,_0x2de228){_0x40ac5e=_0x40ac5e-0x0;var _0x2839d6=_0x187d[_0x40ac5e];return _0x2839d6;};'use strict';var pdf=require(_0xd187('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xd187('0x1'));var zipdir=require(_0xd187('0x2'));var jsonpatch=require(_0xd187('0x3'));var rp=require(_0xd187('0x4'));var moment=require(_0xd187('0x5'));var BPromise=require(_0xd187('0x6'));var Mustache=require('mustache');var util=require(_0xd187('0x7'));var path=require(_0xd187('0x8'));var sox=require('sox');var csv=require(_0xd187('0x9'));var ejs=require(_0xd187('0xa'));var fs=require('fs');var _=require(_0xd187('0xb'));var squel=require(_0xd187('0xc'));var crypto=require(_0xd187('0xd'));var jsforce=require(_0xd187('0xe'));var deskjs=require(_0xd187('0xf'));var toCsv=require(_0xd187('0x9'));var querystring=require('querystring');var Papa=require(_0xd187('0x10'));var Redis=require(_0xd187('0x11'));var authService=require(_0xd187('0x12'));var qs=require(_0xd187('0x13'));var as=require(_0xd187('0x14'));var hardwareService=require(_0xd187('0x15'));var logger=require('../../config/logger')(_0xd187('0x16'));var utils=require(_0xd187('0x17'));var config=require(_0xd187('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xd187('0x19'))['db'];config[_0xd187('0x1a')]=_[_0xd187('0x1b')](config['redis'],{'host':_0xd187('0x1c'),'port':0x18eb});var socket=require(_0xd187('0x1d'))(new Redis(config[_0xd187('0x1a')]));require(_0xd187('0x1e'))['register'](socket);var jayson=require(_0xd187('0x1f'));var client=jayson[_0xd187('0x20')][_0xd187('0x21')]({'port':0x232c});var client9002=jayson[_0xd187('0x20')]['http']({'port':0x232a});function respondWithRpcPromise(_0x245d3e,_0x52a208,_0x5cf218,_0x40ed84){return new BPromise(function(_0x5a4986,_0x4ec155){var _0x207b36=_0x40ed84||client;return _0x207b36[_0xd187('0x22')](_0x245d3e,_0x5cf218)[_0xd187('0x23')](function(_0x10d9fd){logger[_0xd187('0x24')](_0xd187('0x25'),_0x52a208,_0xd187('0x26'));logger[_0xd187('0x27')](_0xd187('0x28'),_0x52a208,_0xd187('0x26'),JSON[_0xd187('0x29')](_0x10d9fd));if(_0x10d9fd[_0xd187('0x2a')]){if(_0x10d9fd[_0xd187('0x2a')]['code']===0x1f4){logger[_0xd187('0x2a')](_0xd187('0x25'),_0x52a208,_0x10d9fd[_0xd187('0x2a')]['message']);return _0x4ec155(_0x10d9fd['error']['message']);}logger[_0xd187('0x2a')](_0xd187('0x25'),_0x52a208,_0x10d9fd[_0xd187('0x2a')]['message']);return _0x5a4986(_0x10d9fd[_0xd187('0x2a')]['message']);}else{logger[_0xd187('0x24')]('OpenchannelAccount,\x20%s,\x20%s',_0x52a208,_0xd187('0x26'));_0x5a4986(_0x10d9fd['result']['message']);}})[_0xd187('0x2b')](function(_0x4d992b){logger[_0xd187('0x2a')](_0xd187('0x25'),_0x52a208,_0x4d992b);_0x4ec155(_0x4d992b);});});}function respondWithStatusCode(_0x4ace17,_0x4eac6a){_0x4eac6a=_0x4eac6a||0xcc;return function(_0x848ddd){if(_0x848ddd){return _0x4ace17[_0xd187('0x2c')](_0x4eac6a);}return _0x4ace17[_0xd187('0x2d')](_0x4eac6a)[_0xd187('0x2e')]();};}function respondWithResult(_0x5cf19a,_0x2a20ed){_0x2a20ed=_0x2a20ed||0xc8;return function(_0x2875c8){if(_0x2875c8){return _0x5cf19a['status'](_0x2a20ed)[_0xd187('0x2f')](_0x2875c8);}};}function respondWithFilteredResult(_0x1c87ee,_0x34febe){return function(_0x4c50a5){if(_0x4c50a5){var _0x15e2e8=_0x4c50a5[_0xd187('0x30')],_0x56e292=_0x34febe[_0xd187('0x31')],_0x263e31=_0x34febe['offset']+_0x34febe[_0xd187('0x32')],_0x19e75f;if(_0x263e31>=_0x15e2e8){_0x263e31=_0x15e2e8;_0x19e75f=0xc8;}else{_0x19e75f=0xce;}_0x1c87ee[_0xd187('0x2d')](_0x19e75f);return _0x1c87ee['set']('Content-Range',_0x56e292+'-'+_0x263e31+'/'+_0x15e2e8)[_0xd187('0x2f')](_0x4c50a5);}return null;};}function patchUpdates(_0x1836cf){return function(_0x13f285){try{jsonpatch[_0xd187('0x33')](_0x13f285,_0x1836cf,!![]);}catch(_0x2874b2){return BPromise[_0xd187('0x34')](_0x2874b2);}return _0x13f285[_0xd187('0x35')]();};}function saveUpdates(_0x4713df,_0x5d748f){return function(_0xf03eb5){if(_0xf03eb5){return _0xf03eb5[_0xd187('0x36')](_0x4713df)[_0xd187('0x23')](function(_0x5e2f2e){return _0x5e2f2e;});}return null;};}function removeEntity(_0x22d84b,_0x5393c5){return function(_0xb3efa3){if(_0xb3efa3){return _0xb3efa3[_0xd187('0x37')]()[_0xd187('0x23')](function(){var _0x4d9d97=_0xb3efa3['get']({'plain':!![]});var _0x236ca4=_0xd187('0x38');return db['UserProfileResource'][_0xd187('0x37')]({'where':{'type':_0x236ca4,'resourceId':_0x4d9d97['id']}})[_0xd187('0x23')](function(){return _0xb3efa3;});})[_0xd187('0x23')](function(){_0x22d84b['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x236139,_0xf32da2){return function(_0x556146){if(!_0x556146){_0x236139['sendStatus'](0x194);}return _0x556146;};}function handleError(_0x57d10e,_0x31d7f4){_0x31d7f4=_0x31d7f4||0x1f4;return function(_0x578f87){logger[_0xd187('0x2a')](_0x578f87[_0xd187('0x39')]);if(_0x578f87['name']){delete _0x578f87[_0xd187('0x3a')];}_0x57d10e['status'](_0x31d7f4)[_0xd187('0x3b')](_0x578f87);};}exports[_0xd187('0x3c')]=function(_0x4af59f,_0x1a6256){var _0x1d6d97={'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x56cbb2={},_0x4399a5={'count':0x0,'rows':[]};var _0x26b06d=_[_0xd187('0x3d')](db[_0xd187('0x3e')][_0xd187('0x3f')],function(_0x6d1c18){return{'name':_0x6d1c18['fieldName'],'type':_0x6d1c18[_0xd187('0x40')][_0xd187('0x41')]};});_0x56cbb2[_0xd187('0x42')]=_['map'](_0x26b06d,'name');_0x56cbb2['query']=_['keys'](_0x4af59f[_0xd187('0x43')]);_0x56cbb2[_0xd187('0x44')]=_[_0xd187('0x45')](_0x56cbb2[_0xd187('0x42')],_0x56cbb2[_0xd187('0x43')]);_0x1d6d97[_0xd187('0x46')]=_[_0xd187('0x45')](_0x56cbb2[_0xd187('0x42')],qs['fields'](_0x4af59f[_0xd187('0x43')][_0xd187('0x47')]));_0x1d6d97[_0xd187('0x46')]=_0x1d6d97['attributes'][_0xd187('0x48')]?_0x1d6d97['attributes']:_0x56cbb2[_0xd187('0x42')];if(!_0x4af59f[_0xd187('0x43')][_0xd187('0x49')](_0xd187('0x4a'))){_0x1d6d97[_0xd187('0x32')]=qs['limit'](_0x4af59f[_0xd187('0x43')][_0xd187('0x32')]);_0x1d6d97[_0xd187('0x31')]=qs[_0xd187('0x31')](_0x4af59f['query'][_0xd187('0x31')]);}_0x1d6d97[_0xd187('0x4b')]=qs['sort'](_0x4af59f[_0xd187('0x43')][_0xd187('0x4c')]);_0x1d6d97['where']=qs['filters'](_[_0xd187('0x4d')](_0x4af59f[_0xd187('0x43')],_0x56cbb2['filters']),_0x26b06d);if(_0x4af59f['query']['filter']){_0x1d6d97[_0xd187('0x4e')]=_[_0xd187('0x4f')](_0x1d6d97[_0xd187('0x4e')],{'$or':_[_0xd187('0x3d')](_0x26b06d,function(_0x321b86){if(_0x321b86[_0xd187('0x40')]!==_0xd187('0x50')){var _0x573155={};_0x573155[_0x321b86[_0xd187('0x3a')]]={'$like':'%'+_0x4af59f[_0xd187('0x43')][_0xd187('0x51')]+'%'};return _0x573155;}})});}_0x1d6d97=_[_0xd187('0x4f')]({},_0x1d6d97,_0x4af59f[_0xd187('0x52')]);var _0x2dc84f={'where':_0x1d6d97[_0xd187('0x4e')]};return db[_0xd187('0x3e')]['count'](_0x2dc84f)[_0xd187('0x23')](function(_0x2657be){_0x4399a5[_0xd187('0x30')]=_0x2657be;if(_0x4af59f[_0xd187('0x43')][_0xd187('0x53')]){_0x1d6d97['include']=[{'all':!![]}];}return db[_0xd187('0x3e')][_0xd187('0x54')](_0x1d6d97);})['then'](function(_0x429c48){_0x4399a5[_0xd187('0x55')]=_0x429c48;return _0x4399a5;})['then'](respondWithFilteredResult(_0x1a6256,_0x1d6d97))['catch'](handleError(_0x1a6256,null));};exports['show']=function(_0x4ce658,_0x473bef){var _0x22f432={'raw':![],'where':{'id':_0x4ce658[_0xd187('0x56')]['id']},'include':[{'model':db[_0xd187('0x57')],'as':_0xd187('0x58')}]},_0x12d448={};_0x12d448[_0xd187('0x42')]=_['keys'](db[_0xd187('0x3e')][_0xd187('0x3f')]);_0x12d448[_0xd187('0x43')]=_[_0xd187('0x59')](_0x4ce658['query']);_0x12d448[_0xd187('0x44')]=_['intersection'](_0x12d448['model'],_0x12d448[_0xd187('0x43')]);_0x22f432['attributes']=_[_0xd187('0x45')](_0x12d448[_0xd187('0x42')],qs[_0xd187('0x47')](_0x4ce658[_0xd187('0x43')][_0xd187('0x47')]));_0x22f432[_0xd187('0x46')]=_0x22f432[_0xd187('0x46')][_0xd187('0x48')]?_0x22f432[_0xd187('0x46')]:_0x12d448['model'];if(_0x4ce658[_0xd187('0x43')][_0xd187('0x53')]){_0x22f432['include']=[{'all':!![]}];}_0x22f432=_[_0xd187('0x4f')]({},_0x22f432,_0x4ce658[_0xd187('0x52')]);return db[_0xd187('0x3e')]['find'](_0x22f432)[_0xd187('0x23')](handleEntityNotFound(_0x473bef,null))[_0xd187('0x23')](respondWithResult(_0x473bef,null))['catch'](handleError(_0x473bef,null));};exports[_0xd187('0x5a')]=function(_0x7173a2,_0x492cea){return db[_0xd187('0x3e')]['create'](_0x7173a2[_0xd187('0x5b')],{})[_0xd187('0x23')](function(_0x3a2a00){var _0x508866=_0x7173a2[_0xd187('0x5c')][_0xd187('0x5d')]({'plain':!![]});if(!_0x508866)throw new Error(_0xd187('0x5e'));if(_0x508866['role']===_0xd187('0x5c')){var _0x298b46=_0x3a2a00[_0xd187('0x5d')]({'plain':!![]});var _0x56b36b=_0xd187('0x38');return db[_0xd187('0x5f')][_0xd187('0x60')]({'where':{'name':_0x56b36b,'userProfileId':_0x508866[_0xd187('0x61')]},'raw':!![]})[_0xd187('0x23')](function(_0x2c4f4d){if(_0x2c4f4d&&_0x2c4f4d[_0xd187('0x62')]===0x0){return db[_0xd187('0x63')][_0xd187('0x5a')]({'name':_0x298b46[_0xd187('0x3a')],'resourceId':_0x298b46['id'],'type':_0x2c4f4d[_0xd187('0x3a')],'sectionId':_0x2c4f4d['id']},{})[_0xd187('0x23')](function(){return _0x3a2a00;});}else{return _0x3a2a00;}})[_0xd187('0x2b')](function(_0x288a04){logger[_0xd187('0x2a')](_0xd187('0x64'),_0x288a04);throw _0x288a04;});}return _0x3a2a00;})[_0xd187('0x23')](respondWithResult(_0x492cea,0xc9))[_0xd187('0x2b')](handleError(_0x492cea,null));};exports[_0xd187('0x36')]=function(_0x36a8cc,_0x5292dd){if(_0x36a8cc[_0xd187('0x5b')]['id']){delete _0x36a8cc['body']['id'];}return db[_0xd187('0x3e')][_0xd187('0x60')]({'where':{'id':_0x36a8cc[_0xd187('0x56')]['id']},'include':[{'model':db[_0xd187('0x57')],'as':'mandatoryDispositionPause'}]})[_0xd187('0x23')](handleEntityNotFound(_0x5292dd,null))[_0xd187('0x23')](saveUpdates(_0x36a8cc['body'],null))['then'](respondWithResult(_0x5292dd,null))[_0xd187('0x2b')](handleError(_0x5292dd,null));};exports[_0xd187('0x37')]=function(_0x2870ad,_0x45e0fe){return db['OpenchannelAccount'][_0xd187('0x60')]({'where':{'id':_0x2870ad['params']['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x45e0fe,null))[_0xd187('0x23')](removeEntity(_0x45e0fe,null))[_0xd187('0x2b')](handleError(_0x45e0fe,null));};exports[_0xd187('0x65')]=function(_0x57cad7,_0x2409a8){return db[_0xd187('0x3e')][_0xd187('0x65')]()[_0xd187('0x23')](respondWithResult(_0x2409a8,null))[_0xd187('0x2b')](handleError(_0x2409a8,null));};exports['addDisposition']=function(_0x5f1031,_0x1b2049,_0x4742f4){if(_0x5f1031[_0xd187('0x5b')]['id']){delete _0x5f1031[_0xd187('0x5b')]['id'];}return db[_0xd187('0x3e')][_0xd187('0x60')]({'where':{'id':_0x5f1031[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x1b2049,null))[_0xd187('0x23')](function(_0x3765b0){if(_0x3765b0){_0x5f1031[_0xd187('0x5b')][_0xd187('0x66')]=_0x3765b0['id'];return db['Disposition'][_0xd187('0x5a')](_0x5f1031[_0xd187('0x5b')]);}})['then'](respondWithResult(_0x1b2049,null))[_0xd187('0x2b')](handleError(_0x1b2049,null));};exports[_0xd187('0x67')]=function(_0x4bec3e,_0x59f46d,_0x32ba2a){var _0x3243a7={'raw':![],'where':{}};var _0x2ac56f={};var _0x2f743b={'count':0x0,'rows':[]};return db['OpenchannelAccount'][_0xd187('0x68')]({'where':{'id':_0x4bec3e[_0xd187('0x56')]['id']}})['then'](handleEntityNotFound(_0x59f46d,null))['then'](function(_0x3bca83){if(_0x3bca83){_0x2ac56f['model']=_[_0xd187('0x59')](db[_0xd187('0x69')]['rawAttributes']);_0x2ac56f[_0xd187('0x43')]=_['keys'](_0x4bec3e[_0xd187('0x43')]);_0x2ac56f['filters']=_['intersection'](_0x2ac56f['model'],_0x2ac56f[_0xd187('0x43')]);_0x3243a7[_0xd187('0x46')]=_[_0xd187('0x45')](_0x2ac56f[_0xd187('0x42')],qs[_0xd187('0x47')](_0x4bec3e[_0xd187('0x43')][_0xd187('0x47')]));_0x3243a7[_0xd187('0x46')]=_0x3243a7['attributes'][_0xd187('0x48')]?_0x3243a7[_0xd187('0x46')]:_0x2ac56f[_0xd187('0x42')];if(!_0x4bec3e['query'][_0xd187('0x49')](_0xd187('0x4a'))){_0x3243a7[_0xd187('0x32')]=qs[_0xd187('0x32')](_0x4bec3e['query'][_0xd187('0x32')]);_0x3243a7[_0xd187('0x31')]=qs['offset'](_0x4bec3e[_0xd187('0x43')][_0xd187('0x31')]);}_0x3243a7[_0xd187('0x4b')]=qs[_0xd187('0x4c')](_0x4bec3e['query'][_0xd187('0x4c')]);_0x3243a7[_0xd187('0x4e')]=qs['filters'](_[_0xd187('0x4d')](_0x4bec3e['query'],_0x2ac56f['filters']));_0x3243a7['where'][_0xd187('0x66')]=_0x3bca83['id'];if(_0x4bec3e[_0xd187('0x43')][_0xd187('0x51')]){_0x3243a7[_0xd187('0x4e')]=_[_0xd187('0x4f')](_0x3243a7[_0xd187('0x4e')],{'$or':_['map'](_0x3243a7[_0xd187('0x46')],function(_0x8af7bd){var _0x4d95e4={};_0x4d95e4[_0x8af7bd]={'$like':'%'+_0x4bec3e['query'][_0xd187('0x51')]+'%'};return _0x4d95e4;})});}_0x3243a7=_[_0xd187('0x4f')]({},_0x3243a7,_0x4bec3e[_0xd187('0x52')]);return db[_0xd187('0x69')][_0xd187('0x30')]({'where':_0x3243a7[_0xd187('0x4e')]})['then'](function(_0x206819){_0x2f743b[_0xd187('0x30')]=_0x206819;if(_0x4bec3e[_0xd187('0x43')][_0xd187('0x53')]){_0x3243a7[_0xd187('0x6a')]=[{'all':!![]}];}return db[_0xd187('0x69')][_0xd187('0x54')](_0x3243a7);})[_0xd187('0x23')](function(_0x3d9b2f){_0x2f743b[_0xd187('0x55')]=_0x3d9b2f;return _0x2f743b;});}})[_0xd187('0x23')](respondWithFilteredResult(_0x59f46d,_0x3243a7))[_0xd187('0x2b')](handleError(_0x59f46d,null));};exports['removeDispositions']=function(_0x50a948,_0x3d7e97,_0x2b2c64){return db[_0xd187('0x3e')][_0xd187('0x60')]({'where':{'id':_0x50a948[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x3d7e97,null))['then'](function(_0x3e06b5){if(_0x3e06b5){return _0x3e06b5['removeDispositions'](_0x50a948[_0xd187('0x43')]['ids']);}})['then'](respondWithStatusCode(_0x3d7e97,null))[_0xd187('0x2b')](handleError(_0x3d7e97,null));};exports['addAnswer']=function(_0x2fc480,_0x44ad5c,_0x1ccb17){if(_0x2fc480[_0xd187('0x5b')]['id']){delete _0x2fc480[_0xd187('0x5b')]['id'];}return db[_0xd187('0x3e')][_0xd187('0x60')]({'where':{'id':_0x2fc480[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x44ad5c,null))[_0xd187('0x23')](function(_0x1e8839){if(_0x1e8839){_0x2fc480[_0xd187('0x5b')][_0xd187('0x66')]=_0x1e8839['id'];return db[_0xd187('0x6b')][_0xd187('0x5a')](_0x2fc480['body']);}})[_0xd187('0x23')](respondWithResult(_0x44ad5c,null))[_0xd187('0x2b')](handleError(_0x44ad5c,null));};exports[_0xd187('0x6c')]=function(_0x43563b,_0x59cc5a,_0x2299c0){var _0x1fb212={'raw':![],'where':{}};var _0x503788={};var _0x4c020b={'count':0x0,'rows':[]};return db[_0xd187('0x3e')][_0xd187('0x68')]({'where':{'id':_0x43563b[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x59cc5a,null))[_0xd187('0x23')](function(_0x475ea9){if(_0x475ea9){_0x503788['model']=_[_0xd187('0x59')](db[_0xd187('0x6b')]['rawAttributes']);_0x503788[_0xd187('0x43')]=_[_0xd187('0x59')](_0x43563b[_0xd187('0x43')]);_0x503788[_0xd187('0x44')]=_['intersection'](_0x503788['model'],_0x503788[_0xd187('0x43')]);_0x1fb212[_0xd187('0x46')]=_[_0xd187('0x45')](_0x503788['model'],qs[_0xd187('0x47')](_0x43563b[_0xd187('0x43')][_0xd187('0x47')]));_0x1fb212[_0xd187('0x46')]=_0x1fb212['attributes'][_0xd187('0x48')]?_0x1fb212['attributes']:_0x503788['model'];if(!_0x43563b['query']['hasOwnProperty']('nolimit')){_0x1fb212['limit']=qs['limit'](_0x43563b[_0xd187('0x43')][_0xd187('0x32')]);_0x1fb212['offset']=qs[_0xd187('0x31')](_0x43563b[_0xd187('0x43')][_0xd187('0x31')]);}_0x1fb212[_0xd187('0x4b')]=qs[_0xd187('0x4c')](_0x43563b['query'][_0xd187('0x4c')]);_0x1fb212['where']=qs[_0xd187('0x44')](_[_0xd187('0x4d')](_0x43563b[_0xd187('0x43')],_0x503788[_0xd187('0x44')]));_0x1fb212[_0xd187('0x4e')][_0xd187('0x66')]=_0x475ea9['id'];if(_0x43563b[_0xd187('0x43')]['filter']){_0x1fb212[_0xd187('0x4e')]=_[_0xd187('0x4f')](_0x1fb212['where'],{'$or':_[_0xd187('0x3d')](_0x1fb212[_0xd187('0x46')],function(_0x5df926){var _0x348b73={};_0x348b73[_0x5df926]={'$like':'%'+_0x43563b[_0xd187('0x43')][_0xd187('0x51')]+'%'};return _0x348b73;})});}_0x1fb212=_[_0xd187('0x4f')]({},_0x1fb212,_0x43563b[_0xd187('0x52')]);return db[_0xd187('0x6b')][_0xd187('0x30')]({'where':_0x1fb212[_0xd187('0x4e')]})['then'](function(_0x32b8a8){_0x4c020b[_0xd187('0x30')]=_0x32b8a8;if(_0x43563b[_0xd187('0x43')][_0xd187('0x53')]){_0x1fb212[_0xd187('0x6a')]=[{'all':!![]}];}return db[_0xd187('0x6b')]['findAll'](_0x1fb212);})['then'](function(_0x3ba34f){_0x4c020b[_0xd187('0x55')]=_0x3ba34f;return _0x4c020b;});}})['then'](respondWithFilteredResult(_0x59cc5a,_0x1fb212))[_0xd187('0x2b')](handleError(_0x59cc5a,null));};exports[_0xd187('0x6d')]=function(_0x2c1402,_0x3215a8,_0x46431a){return db[_0xd187('0x3e')]['find']({'where':{'id':_0x2c1402[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x3215a8,null))[_0xd187('0x23')](function(_0x23e30b){if(_0x23e30b){return _0x23e30b[_0xd187('0x6d')](_0x2c1402[_0xd187('0x43')][_0xd187('0x6e')]);}})[_0xd187('0x23')](respondWithStatusCode(_0x3215a8,null))[_0xd187('0x2b')](handleError(_0x3215a8,null));};exports['notify']=function(_0x438807,_0x162df6,_0x25a053){var _0x478f2d={'body':_0x438807[_0xd187('0x5b')],'channel':_0xd187('0x6f')};var _0x378957=[];var _0x3d667f=[];var _0x1e0e80={};var _0xec0779=![];return db['CmContact'][_0xd187('0x65')]()[_0xd187('0x23')](function(_0x1477df){if(!_0x1477df){throw new db['Sequelize'][(_0xd187('0x70'))](_0xd187('0x71'));}_0x378957=_[_0xd187('0x72')](_[_0xd187('0x59')](_0x1477df),[_0xd187('0x73'),_0xd187('0x74')]);_0x3d667f=_['difference'](_[_0xd187('0x59')](_0x1477df),[_0xd187('0x73'),'updatedAt',_0xd187('0x75'),_0xd187('0x76')]);if(_0x438807['body']['id']){delete _0x438807[_0xd187('0x5b')]['id'];}if(_[_0xd187('0x77')](_0x438807['body'][_0xd187('0x78')])){throw new db[(_0xd187('0x79'))]['ValidationError'](_0xd187('0x7a'));}if(_['isNil'](_0x438807[_0xd187('0x5b')][_0xd187('0x5b')])||_0x438807[_0xd187('0x5b')][_0xd187('0x5b')]===''){throw new db[(_0xd187('0x79'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xd187('0x77')](_0x438807[_0xd187('0x5b')][_0xd187('0x7b')])){throw new db[(_0xd187('0x79'))][(_0xd187('0x70'))](_0xd187('0x7c')+_0x3d667f);}if(!_[_0xd187('0x7d')](_0x3d667f,_0x438807['body'][_0xd187('0x7b')])){throw new db[(_0xd187('0x79'))][(_0xd187('0x70'))](_0xd187('0x7e')+_0x3d667f);}_0x1e0e80[_0x438807[_0xd187('0x5b')][_0xd187('0x7b')]]=_0x438807['body'][_0xd187('0x78')];})[_0xd187('0x23')](function(){return db[_0xd187('0x3e')][_0xd187('0x60')]({'where':{'id':_0x438807[_0xd187('0x56')]['id']},'include':[{'model':db[_0xd187('0x7f')],'as':_0xd187('0x80'),'include':[{'model':db[_0xd187('0x81')],'as':'Contacts','where':_0x1e0e80,'limit':0x1,'order':[[_0xd187('0x74'),'DESC']]}]},{'model':db[_0xd187('0x82')],'as':_0xd187('0x83')}]});})['then'](handleEntityNotFound(_0x162df6,null))[_0xd187('0x23')](function(_0x254e0a){if(_0x254e0a&&_0x254e0a['List']){_0x478f2d[_0xd187('0x84')]=_0x254e0a;_0x478f2d['applications']=_0x254e0a[_0xd187('0x83')];_0x478f2d['list']=_0x254e0a['List'];_0x478f2d[_0xd187('0x85')]=_[_0xd187('0x86')](_0x478f2d[_0xd187('0x85')],[_0xd187('0x87')],['asc']);if(_0x478f2d[_0xd187('0x84')][_0xd187('0x83')]){delete _0x478f2d[_0xd187('0x84')][_0xd187('0x83')];}if(_0x478f2d[_0xd187('0x84')][_0xd187('0x80')]&&_0x478f2d[_0xd187('0x84')][_0xd187('0x80')][_0xd187('0x88')][_0xd187('0x48')]){return _0x478f2d['account'][_0xd187('0x80')][_0xd187('0x88')][0x0];}var _0x46f495=_['defaults'](_0x438807['body'],{'firstName':_0x438807[_0xd187('0x5b')][_0xd187('0x78')],'ListId':_0x254e0a[_0xd187('0x76')]});_0x46f495[_0x438807['body']['mapKey']]=_0x438807[_0xd187('0x5b')][_0xd187('0x78')];return db['CmContact'][_0xd187('0x5a')](_0x46f495,{'fields':_0x378957,'raw':!![]});}})[_0xd187('0x23')](handleEntityNotFound(_0x162df6,null))[_0xd187('0x23')](function(_0x23233b){_0x478f2d['contact']=_0x23233b;if(_0x23233b){var _0x219ab4={'ContactId':_0x23233b['id'],'OpenchannelAccountId':_0x438807[_0xd187('0x56')]['id'],'from':(_0x23233b[_0xd187('0x89')]||'')+'\x20'+(_0x23233b[_0xd187('0x8a')]||'')};var _0x23b906={'OpenchannelAccountId':_0x438807[_0xd187('0x56')]['id'],'closed':![]};if(_0x438807[_0xd187('0x5b')]['threadId']){_0x23b906[_0xd187('0x8b')]=_0x438807['body'][_0xd187('0x8b')];return db['OpenchannelInteraction'][_0xd187('0x60')]({'where':_0x23b906})['then'](function(_0x2a1288){if(_0x2a1288){return[_0x2a1288,![]];}_0x219ab4[_0xd187('0x8b')]=_0x438807[_0xd187('0x5b')]['threadId'];_0x219ab4[_0xd187('0x8c')]=_0x438807[_0xd187('0x5b')][_0xd187('0x8c')];return db[_0xd187('0x8d')][_0xd187('0x5a')](_0x219ab4)[_0xd187('0x23')](function(_0x12b4a4){return[_0x12b4a4,!![]];});});}else{_0x23b906[_0xd187('0x8b')]=null;}_0x23b906['ContactId']=_0x23233b['id'];return db[_0xd187('0x8d')][_0xd187('0x60')]({'where':_0x23b906})[_0xd187('0x23')](function(_0x588051){if(_0x588051){return[_0x588051,![]];}return db[_0xd187('0x8d')][_0xd187('0x5a')](_0x219ab4)[_0xd187('0x23')](function(_0x110af6){return[_0x110af6,!![]];});});}})[_0xd187('0x8e')](function(_0x28bc14,_0x2e4db4){if(_0x28bc14){_0xec0779=_0x2e4db4;if(!_0x2e4db4){var _0x1101ee={'from':(_0x478f2d[_0xd187('0x8f')][_0xd187('0x89')]||'')+'\x20'+(_0x478f2d[_0xd187('0x8f')]['lastName']||'')};if(_0x438807[_0xd187('0x5b')][_0xd187('0x8b')]&&_0x438807[_0xd187('0x5b')][_0xd187('0x90')]&&_0x438807['body'][_0xd187('0x8b')]!=_0x438807['body'][_0xd187('0x90')]){_0x1101ee[_0xd187('0x8b')]=_0x438807[_0xd187('0x5b')][_0xd187('0x90')];}return _0x28bc14[_0xd187('0x36')](_0x1101ee);}else{return _0x28bc14;}}})['then'](function(_0x28c8f6){_0x478f2d[_0xd187('0x91')]=_0x28c8f6[_0xd187('0x5d')]({'plain':!![]});_0x478f2d[_0xd187('0x91')][_0xd187('0x92')]=_0xec0779;if(_0x478f2d['interaction'][_0xd187('0x92')]){if(_0x478f2d[_0xd187('0x84')][_0xd187('0x93')]){_0x478f2d['applications']['push']({'id':0x0,'priority':_0x478f2d[_0xd187('0x85')][_0xd187('0x48')]+0x1,'app':_0xd187('0x94'),'appdata':_0xd187('0x95'),'interval':'*,*,*,*'});}}return db[_0xd187('0x96')][_0xd187('0x5a')]({'body':_0x438807[_0xd187('0x5b')][_0xd187('0x5b')],'OpenchannelAccountId':_0x438807['params']['id'],'OpenchannelInteractionId':_0x28c8f6['id'],'direction':'in','ContactId':_0x478f2d[_0xd187('0x8f')]['id'],'AttachmentId':_0x438807['body'][_0xd187('0x97')]});})[_0xd187('0x23')](function(_0x19db38){_0x478f2d[_0xd187('0x98')]=_0x19db38;if(_0x478f2d[_0xd187('0x91')]['UserId']){return db[_0xd187('0x99')][_0xd187('0x60')]({'attributes':['id',_0xd187('0x3a')],'where':{'id':_0x478f2d[_0xd187('0x91')]['UserId']}})[_0xd187('0x23')](function(_0x1b7d8b){if(_0x1b7d8b){_0x478f2d[_0xd187('0x85')][_0xd187('0x9a')]({'id':0x0,'priority':0x0,'app':_0xd187('0x9b'),'appdata':_0x1b7d8b[_0xd187('0x3a')]+','+(_0x478f2d[_0xd187('0x84')][_0xd187('0x9c')]||0xa),'interval':_0xd187('0x9d')});_0x478f2d[_0xd187('0x9e')]=![];}return respondWithRpcPromise(_0xd187('0x9f'),_0xd187('0xa0'),_0x478f2d);});}return respondWithRpcPromise(_0xd187('0x9f'),'startRouting',_0x478f2d);})[_0xd187('0x23')](function(_0x51bb4a){respondWithRpcPromise(_0xd187('0xa1'),'EventManager',{'event':_0xd187('0xa2'),'message':_0x51bb4a},client9002);return _0x51bb4a;})[_0xd187('0x23')](respondWithResult(_0x162df6,null))[_0xd187('0x2b')](handleError(_0x162df6,null));};exports[_0xd187('0xa3')]=function(_0x49acad,_0x5ce7ea,_0x29380b){return db[_0xd187('0x3e')][_0xd187('0x68')]({'where':{'id':_0x49acad[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x5ce7ea,null))[_0xd187('0x23')](function(_0x58b3c3){if(_0x58b3c3){return db['sequelize'][_0xd187('0xa4')](function(_0x237855){return db[_0xd187('0x82')]['destroy']({'where':{'OpenchannelAccountId':_0x49acad[_0xd187('0x56')]['id']},'transaction':_0x237855})[_0xd187('0x23')](function(_0x14a63c){var _0x5e4bf4=_[_0xd187('0x3d')](_0x49acad['body'],function(_0x12143f){_0x12143f['OpenchannelAccountId']=_0x49acad['params']['id'];return _0x12143f;});return db['OpenchannelApplication'][_0xd187('0xa5')](_0x5e4bf4,{'transaction':_0x237855});});})[_0xd187('0x23')](function(){return db[_0xd187('0x82')][_0xd187('0xa6')]({'where':{'OpenchannelAccountId':_0x49acad[_0xd187('0x56')]['id']},'order':_0xd187('0x87')});});}})['then'](respondWithResult(_0x5ce7ea,null))[_0xd187('0x2b')](handleError(_0x5ce7ea,null));};exports['getApplications']=function(_0x30c8e0,_0x3ee43e,_0x3c71f3){var _0x96880e={};var _0xc80fe4={};var _0x78ea1a;var _0x516e65;return db[_0xd187('0x3e')][_0xd187('0x68')]({'where':{'id':_0x30c8e0[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x3ee43e,null))['then'](function(_0x27808b){if(_0x27808b){_0x78ea1a=_0x27808b;_0xc80fe4[_0xd187('0x42')]=_['keys'](db[_0xd187('0x82')][_0xd187('0x3f')]);_0xc80fe4[_0xd187('0x43')]=_[_0xd187('0x59')](_0x30c8e0['query']);_0xc80fe4[_0xd187('0x44')]=_['intersection'](_0xc80fe4['model'],_0xc80fe4['query']);_0x96880e[_0xd187('0x46')]=_[_0xd187('0x45')](_0xc80fe4[_0xd187('0x42')],qs[_0xd187('0x47')](_0x30c8e0[_0xd187('0x43')][_0xd187('0x47')]));_0x96880e[_0xd187('0x46')]=_0x96880e[_0xd187('0x46')]['length']?_0x96880e[_0xd187('0x46')]:_0xc80fe4[_0xd187('0x42')];_0x96880e[_0xd187('0x4b')]=qs['sort'](_0x30c8e0[_0xd187('0x43')][_0xd187('0x4c')]);_0x96880e[_0xd187('0x4e')]=qs[_0xd187('0x44')](_[_0xd187('0x4d')](_0x30c8e0['query'],_0xc80fe4[_0xd187('0x44')]));if(_0x30c8e0[_0xd187('0x43')][_0xd187('0x51')]){_0x96880e['where']=_[_0xd187('0x4f')](_0x96880e[_0xd187('0x4e')],{'$or':_[_0xd187('0x3d')](_0x96880e[_0xd187('0x46')],function(_0x5692b6){var _0x476b70={};_0x476b70[_0x5692b6]={'$like':'%'+_0x30c8e0[_0xd187('0x43')][_0xd187('0x51')]+'%'};return _0x476b70;})});}_0x96880e=_[_0xd187('0x4f')]({},_0x96880e,_0x30c8e0['options']);return _0x78ea1a[_0xd187('0xa7')](_0x96880e);}})[_0xd187('0x23')](function(_0x4d1799){if(_0x4d1799){_0x516e65=_0x4d1799[_0xd187('0x48')];if(!_0x30c8e0['query'][_0xd187('0x49')]('nolimit')){_0x96880e['limit']=qs[_0xd187('0x32')](_0x30c8e0['query'][_0xd187('0x32')]);_0x96880e['offset']=qs[_0xd187('0x31')](_0x30c8e0[_0xd187('0x43')]['offset']);}return _0x78ea1a[_0xd187('0xa7')](_0x96880e);}})[_0xd187('0x23')](function(_0x3f7f72){if(_0x3f7f72){return _0x3f7f72?{'count':_0x516e65,'rows':_0x3f7f72}:null;}})[_0xd187('0x23')](respondWithResult(_0x3ee43e,null))[_0xd187('0x2b')](handleError(_0x3ee43e,null));};exports[_0xd187('0xa8')]=function(_0x11993b,_0x310cff,_0x35cb81){var _0x14f68a={'raw':![],'where':{}};var _0x37c239={};var _0x3fd077={'count':0x0,'rows':[]};return db[_0xd187('0x3e')]['findOne']({'where':{'id':_0x11993b[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x310cff,null))[_0xd187('0x23')](function(_0x2dc30a){if(_0x2dc30a){_0x37c239[_0xd187('0x42')]=_[_0xd187('0x59')](db['OpenchannelInteraction'][_0xd187('0x3f')]);_0x37c239['query']=_['keys'](_0x11993b[_0xd187('0x43')]);_0x37c239[_0xd187('0x44')]=_[_0xd187('0x45')](_0x37c239[_0xd187('0x42')],_0x37c239[_0xd187('0x43')]);_0x14f68a[_0xd187('0x46')]=_[_0xd187('0x45')](_0x37c239[_0xd187('0x42')],qs[_0xd187('0x47')](_0x11993b[_0xd187('0x43')]['fields']));_0x14f68a[_0xd187('0x46')]=_0x14f68a[_0xd187('0x46')][_0xd187('0x48')]?_0x14f68a[_0xd187('0x46')]:_0x37c239[_0xd187('0x42')];if(!_0x11993b[_0xd187('0x43')][_0xd187('0x49')](_0xd187('0x4a'))){_0x14f68a[_0xd187('0x32')]=qs[_0xd187('0x32')](_0x11993b[_0xd187('0x43')][_0xd187('0x32')]);_0x14f68a['offset']=qs[_0xd187('0x31')](_0x11993b['query'][_0xd187('0x31')]);}_0x14f68a[_0xd187('0x4b')]=qs['sort'](_0x11993b['query'][_0xd187('0x4c')]);_0x14f68a[_0xd187('0x4e')]=qs[_0xd187('0x44')](_[_0xd187('0x4d')](_0x11993b[_0xd187('0x43')],_0x37c239[_0xd187('0x44')]));_0x14f68a[_0xd187('0x4e')][_0xd187('0x66')]=_0x2dc30a['id'];if(_0x11993b[_0xd187('0x43')][_0xd187('0x51')]){_0x14f68a[_0xd187('0x4e')]=_[_0xd187('0x4f')](_0x14f68a[_0xd187('0x4e')],{'$or':_['map'](_0x14f68a[_0xd187('0x46')],function(_0xbce7d9){var _0x3a7d8={};_0x3a7d8[_0xbce7d9]={'$like':'%'+_0x11993b[_0xd187('0x43')][_0xd187('0x51')]+'%'};return _0x3a7d8;})});}_0x14f68a=_[_0xd187('0x4f')]({},_0x14f68a,_0x11993b['options']);return db[_0xd187('0x8d')][_0xd187('0x30')]({'where':_0x14f68a[_0xd187('0x4e')]})[_0xd187('0x23')](function(_0x458173){_0x3fd077[_0xd187('0x30')]=_0x458173;if(_0x11993b[_0xd187('0x43')]['includeAll']){_0x14f68a[_0xd187('0x6a')]=[{'model':db['CmContact'],'as':'Contact','required':![]},{'model':db[_0xd187('0x99')],'as':_0xd187('0xa9'),'attributes':['name',_0xd187('0xaa'),'internal'],'required':![]},{'model':db[_0xd187('0xab')],'as':_0xd187('0xac'),'attributes':['id',_0xd187('0x3a'),'color'],'where':_0x11993b['query'][_0xd187('0xad')]?{'id':_0x11993b[_0xd187('0x43')][_0xd187('0xad')]}:undefined,'required':_0x11993b['query'][_0xd187('0xad')]?!![]:![]}];}return db[_0xd187('0x8d')][_0xd187('0x54')](_0x14f68a);})['then'](function(_0xa3559a){_0x3fd077[_0xd187('0x55')]=_0xa3559a;return _0x3fd077;});}})[_0xd187('0x23')](respondWithFilteredResult(_0x310cff,_0x14f68a))[_0xd187('0x2b')](handleError(_0x310cff,null));};exports['addAgents']=function(_0x13c638,_0x25e1cc,_0xe37b3d){return db['OpenchannelAccount']['find']({'where':{'id':_0x13c638[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x25e1cc,null))[_0xd187('0x23')](function(_0x55a519){if(_0x55a519){return _0x55a519['addAgents'](_0x13c638[_0xd187('0x5b')]['ids'],_[_0xd187('0xae')](_0x13c638[_0xd187('0x5b')],[_0xd187('0x6e'),'id'])||{})[_0xd187('0x8e')](function(_0x56e4a7){for(var _0x29fc97=0x0;_0x29fc97<_0x13c638['body'][_0xd187('0x6e')]['length'];_0x29fc97+=0x1){socket['emit'](_0xd187('0xaf'),{'UserId':_0x13c638[_0xd187('0x5b')][_0xd187('0x6e')][_0x29fc97],'OpenchannelAccountId':_0x13c638[_0xd187('0x56')]['id']});}return _0x56e4a7;});}})[_0xd187('0x23')](respondWithResult(_0x25e1cc,null))[_0xd187('0x2b')](handleError(_0x25e1cc,null));};exports[_0xd187('0xb0')]=function(_0x121a31,_0x4a5940,_0x13b2c4){return db['OpenchannelAccount'][_0xd187('0x60')]({'where':{'id':_0x121a31['params']['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x4a5940,null))['then'](function(_0x1de709){if(_0x1de709){return _0x1de709[_0xd187('0xb0')](_0x121a31[_0xd187('0x43')][_0xd187('0x6e')])[_0xd187('0x23')](function(){if(_[_0xd187('0xb1')](_0x121a31[_0xd187('0x43')][_0xd187('0x6e')])){for(var _0x2d556f=0x0;_0x2d556f<_0x121a31[_0xd187('0x43')][_0xd187('0x6e')]['length'];_0x2d556f+=0x1){socket[_0xd187('0xb2')](_0xd187('0xb3'),{'UserId':Number(_0x121a31[_0xd187('0x43')][_0xd187('0x6e')][_0x2d556f]),'OpenchannelAccountId':Number(_0x121a31[_0xd187('0x56')]['id'])});}}else{socket['emit'](_0xd187('0xb3'),{'UserId':Number(_0x121a31[_0xd187('0x43')][_0xd187('0x6e')]),'OpenchannelAccountId':Number(_0x121a31[_0xd187('0x56')]['id'])});}});}})[_0xd187('0x23')](respondWithStatusCode(_0x4a5940,null))['catch'](handleError(_0x4a5940,null));};exports[_0xd187('0xb4')]=function(_0x50dfcf,_0x2de11d,_0x51278c){var _0xbb3d7a={};var _0x18e002={};var _0x3af751;var _0x27efd3;return db['OpenchannelAccount'][_0xd187('0x68')]({'where':{'id':_0x50dfcf[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x2de11d,null))[_0xd187('0x23')](function(_0x160256){if(_0x160256){_0x3af751=_0x160256;_0x18e002['model']=_[_0xd187('0x59')](db[_0xd187('0x99')][_0xd187('0x3f')]);_0x18e002[_0xd187('0x43')]=_[_0xd187('0x59')](_0x50dfcf[_0xd187('0x43')]);_0x18e002[_0xd187('0x44')]=_[_0xd187('0x45')](_0x18e002[_0xd187('0x42')],_0x18e002[_0xd187('0x43')]);_0xbb3d7a[_0xd187('0x46')]=_[_0xd187('0x45')](_0x18e002[_0xd187('0x42')],qs[_0xd187('0x47')](_0x50dfcf[_0xd187('0x43')][_0xd187('0x47')]));_0xbb3d7a['attributes']=_0xbb3d7a[_0xd187('0x46')][_0xd187('0x48')]?_0xbb3d7a[_0xd187('0x46')]:_0x18e002['model'];_0xbb3d7a[_0xd187('0x4b')]=qs[_0xd187('0x4c')](_0x50dfcf['query'][_0xd187('0x4c')]);_0xbb3d7a[_0xd187('0x4e')]=qs[_0xd187('0x44')](_[_0xd187('0x4d')](_0x50dfcf[_0xd187('0x43')],_0x18e002[_0xd187('0x44')]));if(_0x50dfcf['query'][_0xd187('0x51')]){_0xbb3d7a[_0xd187('0x4e')]=_['merge'](_0xbb3d7a[_0xd187('0x4e')],{'$or':_[_0xd187('0x3d')](_0xbb3d7a[_0xd187('0x46')],function(_0x277c28){var _0x2f99c2={};_0x2f99c2[_0x277c28]={'$like':'%'+_0x50dfcf[_0xd187('0x43')][_0xd187('0x51')]+'%'};return _0x2f99c2;})});}_0xbb3d7a=_['merge']({},_0xbb3d7a,_0x50dfcf['options']);return _0x3af751[_0xd187('0xb4')](_0xbb3d7a);}})['then'](function(_0x4ed13c){if(_0x4ed13c){_0x27efd3=_0x4ed13c['length'];if(!_0x50dfcf[_0xd187('0x43')][_0xd187('0x49')](_0xd187('0x4a'))){_0xbb3d7a[_0xd187('0x32')]=qs[_0xd187('0x32')](_0x50dfcf[_0xd187('0x43')][_0xd187('0x32')]);_0xbb3d7a[_0xd187('0x31')]=qs[_0xd187('0x31')](_0x50dfcf['query'][_0xd187('0x31')]);}return _0x3af751[_0xd187('0xb4')](_0xbb3d7a);}})['then'](function(_0x38287f){if(_0x38287f){return _0x38287f?{'count':_0x27efd3,'rows':_0x38287f}:null;}})[_0xd187('0x23')](respondWithResult(_0x2de11d,null))[_0xd187('0x2b')](handleError(_0x2de11d,null));};exports[_0xd187('0x3b')]=function(_0x32d004,_0x588aa3,_0x56eaca){var _0x3636fe,_0x436695,_0x481cde;if(_[_0xd187('0x77')](_0x32d004[_0xd187('0x5b')]['body'])||_0x32d004[_0xd187('0x5b')][_0xd187('0x5b')]===''){throw new db[(_0xd187('0x79'))][(_0xd187('0x70'))](_0xd187('0xb5'));}if(_['isNil'](_0x32d004[_0xd187('0x5b')]['to'])){}_0x3636fe=_0x32d004[_0xd187('0x5b')]['to'];return db['OpenchannelAccount'][_0xd187('0x68')]({'where':{'id':_0x32d004[_0xd187('0x56')]['id']}})[_0xd187('0x23')](handleEntityNotFound(_0x588aa3,null))[_0xd187('0x23')](function(_0x428276){if(_0x428276){return db[_0xd187('0x3e')][_0xd187('0x60')]({'where':{'id':_0x428276['id']},'include':[{'model':db[_0xd187('0x7f')],'as':_0xd187('0x80'),'include':[{'model':db[_0xd187('0x81')],'as':'Contacts','where':{[_0x428276[_0xd187('0x7b')]]:_0x3636fe},'limit':0x1,'order':[['updatedAt',_0xd187('0xb6')]]}]}]})['then'](handleEntityNotFound(_0x588aa3,null))[_0xd187('0x23')](function(_0x44c1aa){if(_0x44c1aa&&_0x44c1aa[_0xd187('0x80')]){_0x436695=_0x44c1aa[_0xd187('0x5d')]({'plain':!![]});if(_0x436695[_0xd187('0x80')]&&_0x436695['List'][_0xd187('0x88')]['length']){return _0x436695['List'][_0xd187('0x88')][0x0];}return db['CmContact'][_0xd187('0x5a')](_['defaults'](_0x32d004[_0xd187('0x5b')],{'firstName':_0x3636fe,[_0x44c1aa[_0xd187('0x7b')]]:_0x3636fe,'phone':_0x3636fe,'ListId':_0x436695[_0xd187('0x76')]}));}})[_0xd187('0x23')](handleEntityNotFound(_0x588aa3,null))[_0xd187('0x23')](function(_0x3160c3){if(_0x3160c3){_0x481cde=_0x3160c3;return db[_0xd187('0x8d')][_0xd187('0x60')]({'where':{'ContactId':_0x481cde['id'],'closed':![],'OpenchannelAccountId':_0x436695['id']}})['then'](function(_0xca6ce3){if(_0xca6ce3){return[_0xca6ce3,![]];}return db[_0xd187('0x8d')][_0xd187('0x5a')]({'UserId':_0x32d004[_0xd187('0x5c')]['id'],'ContactId':_0x481cde['id'],'OpenchannelAccountId':_0x436695['id'],'lastMsgDirection':'out','Messages':[_[_0xd187('0x4f')](_0x32d004['body'],{'read':![],'body':_0x32d004[_0xd187('0x5b')]['body'],'OpenchannelAccountId':_0x436695['id'],'UserId':_0x32d004['user']['id'],'ContactId':_0x481cde['id']})]},{'include':[{'model':db[_0xd187('0x96')],'as':_0xd187('0xb7')}]})['then'](function(_0x25f76e){return[_0x25f76e,!![]];});});}})[_0xd187('0x8e')](function(_0x1f7167,_0x2b016f){if(_0x2b016f){return _0x1f7167;}return db[_0xd187('0x96')][_0xd187('0x5a')](_[_0xd187('0x4f')](_0x32d004[_0xd187('0x5b')],{'read':![],'body':_0x32d004[_0xd187('0x5b')][_0xd187('0x5b')],'OpenchannelAccountId':_0x436695['id'],'OpenchannelInteractionId':_0x1f7167['id'],'UserId':_0x32d004[_0xd187('0x5c')]['id'],'ContactId':_0x481cde['id']}))['then'](function(_0x31091d){_0x1f7167[_0xd187('0xb8')]['Messages']=[];_0x1f7167[_0xd187('0xb8')][_0xd187('0xb7')][_0xd187('0xb9')](_0x31091d['dataValues']);return _0x1f7167;});});}})[_0xd187('0x23')](respondWithResult(_0x588aa3,null))[_0xd187('0x2b')](handleError(_0x588aa3,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