Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index 4c2758f..20fd3ad 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf759=['appdata','push','Answer','CDR(type)=inbound-fax','localstationid','faxdetect','headerinfo','maxrate','minrate','modem','t38timeout','FAXOPT(','Wait','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','ReceiveFax','updateAccountApplications','VoiceExtension','tech','updatedAt','ListId','findById','getMessages','FaxMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','DESC','attachments','root','basename','CheckAfterSend','isNil','from','fax','List','Contacts','List\x20not\x20found','Send\x20Fax\x20failed','out','filename','Messages','Contact\x20not\x20found','spread','ContactId','dataValues','SendFaxRpc,\x20%s','addAgents','omit','emit','userFaxAccount:save','removeAgents','userFaxAccount:remove','getAgents','html-pdf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./faxAccount.socket','jayson/promise','http','client','Sequelize','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','status','end','count','offset','limit','set','json','apply','reject','update','destroy','get','FaxAccounts','UserProfileResource','sendStatus','stack','name','send','index','Pause','mandatoryDispositionPause','map','type','key','model','query','filters','intersection','fields','attributes','length','nolimit','order','sort','where','pick','filter','VIRTUAL','options','FaxAccount','includeAll','include','findAll','rows','show','params','keys','merge','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','Disposition','findOne','rawAttributes','hasOwnProperty','FaxAccountId','removeDispositions','ids','getAnswers','CannedAnswer','removeAnswers','addInteraction','FaxInteraction','getInteractions','CmContact','User','Owner','fullname','Tag','tag','addApplications','sequelize','transaction','FaxApplication','bulkCreate','findAndCountAll','priority','getApplications','exten','app','system','description'];(function(_0x253b64,_0x2f698e){var _0x3fe515=function(_0x44596e){while(--_0x44596e){_0x253b64['push'](_0x253b64['shift']());}};_0x3fe515(++_0x2f698e);}(_0xf759,0xf3));var _0x9f75=function(_0x3fabd0,_0x5c7a49){_0x3fabd0=_0x3fabd0-0x0;var _0x27fc24=_0xf759[_0x3fabd0];return _0x27fc24;};'use strict';var pdf=require(_0x9f75('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x9f75('0x1'));var jsonpatch=require(_0x9f75('0x2'));var rp=require(_0x9f75('0x3'));var moment=require(_0x9f75('0x4'));var BPromise=require(_0x9f75('0x5'));var Mustache=require(_0x9f75('0x6'));var util=require(_0x9f75('0x7'));var path=require(_0x9f75('0x8'));var sox=require('sox');var csv=require(_0x9f75('0x9'));var ejs=require(_0x9f75('0xa'));var fs=require('fs');var _=require(_0x9f75('0xb'));var squel=require(_0x9f75('0xc'));var crypto=require(_0x9f75('0xd'));var jsforce=require(_0x9f75('0xe'));var deskjs=require(_0x9f75('0xf'));var toCsv=require('to-csv');var querystring=require(_0x9f75('0x10'));var Papa=require('papaparse');var Redis=require(_0x9f75('0x11'));var authService=require(_0x9f75('0x12'));var qs=require(_0x9f75('0x13'));var as=require(_0x9f75('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9f75('0x15'))('api');var utils=require('../../config/utils');var config=require(_0x9f75('0x16'));var db=require(_0x9f75('0x17'))['db'];config[_0x9f75('0x18')]=_[_0x9f75('0x19')](config[_0x9f75('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0x9f75('0x1a'))(new Redis(config['redis']));require(_0x9f75('0x1b'))['register'](socket);var jayson=require(_0x9f75('0x1c'));var client=jayson['client'][_0x9f75('0x1d')]({'port':0x232c});var client9002=jayson[_0x9f75('0x1e')][_0x9f75('0x1d')]({'port':0x232a});function checkPasswordPattern(_0x186168,_0x53bcc8,_0x65ec0b){if(_0x65ec0b){var _0x36090b=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x36090b['test'](_0x53bcc8)){return _0x186168;}else{throw new db[(_0x9f75('0x1f'))]['ValidationError'](_0x9f75('0x20'));}}else{return _0x186168;}}function respondWithRpcPromise(_0x25cc32,_0x2833a8,_0x56bb83,_0x5a0374){return new BPromise(function(_0x3b35f1,_0x33f08c){var _0xff30eb=_0x5a0374||client;return _0xff30eb[_0x9f75('0x21')](_0x25cc32,_0x56bb83)[_0x9f75('0x22')](function(_0x8f9cfb){logger[_0x9f75('0x23')](_0x9f75('0x24'),_0x2833a8,_0x9f75('0x25'));logger[_0x9f75('0x26')]('FaxAccount,\x20%s,\x20%s,\x20%s',_0x2833a8,_0x9f75('0x25'),JSON[_0x9f75('0x27')](_0x8f9cfb));if(_0x8f9cfb[_0x9f75('0x28')]){if(_0x8f9cfb[_0x9f75('0x28')]['code']===0x1f4){logger['error'](_0x9f75('0x24'),_0x2833a8,_0x8f9cfb[_0x9f75('0x28')][_0x9f75('0x29')]);return _0x33f08c(_0x8f9cfb[_0x9f75('0x28')]['message']);}logger[_0x9f75('0x28')](_0x9f75('0x24'),_0x2833a8,_0x8f9cfb[_0x9f75('0x28')]['message']);return _0x3b35f1(_0x8f9cfb[_0x9f75('0x28')][_0x9f75('0x29')]);}else{logger[_0x9f75('0x23')]('FaxAccount,\x20%s,\x20%s',_0x2833a8,_0x9f75('0x25'));_0x3b35f1(_0x8f9cfb[_0x9f75('0x2a')]['message']);}})[_0x9f75('0x2b')](function(_0x44c206){logger['error'](_0x9f75('0x24'),_0x2833a8,_0x44c206);_0x33f08c(_0x44c206);});});}function respondWithStatusCode(_0x2b93e3,_0x1edb62){_0x1edb62=_0x1edb62||0xcc;return function(_0x5c5357){if(_0x5c5357){return _0x2b93e3['sendStatus'](_0x1edb62);}return _0x2b93e3[_0x9f75('0x2c')](_0x1edb62)[_0x9f75('0x2d')]();};}function respondWithResult(_0x4a18c1,_0x49e906){_0x49e906=_0x49e906||0xc8;return function(_0x39cf4b){if(_0x39cf4b){return _0x4a18c1['status'](_0x49e906)['json'](_0x39cf4b);}};}function respondWithFilteredResult(_0x4b4da7,_0x4740e4){return function(_0x36fc0b){if(_0x36fc0b){var _0x998c8b=_0x36fc0b[_0x9f75('0x2e')],_0x1f9199=_0x4740e4[_0x9f75('0x2f')],_0x401607=_0x4740e4[_0x9f75('0x2f')]+_0x4740e4[_0x9f75('0x30')],_0x528f85;if(_0x401607>=_0x998c8b){_0x401607=_0x998c8b;_0x528f85=0xc8;}else{_0x528f85=0xce;}_0x4b4da7[_0x9f75('0x2c')](_0x528f85);return _0x4b4da7[_0x9f75('0x31')]('Content-Range',_0x1f9199+'-'+_0x401607+'/'+_0x998c8b)[_0x9f75('0x32')](_0x36fc0b);}return null;};}function patchUpdates(_0x5b8062){return function(_0x1efc7e){try{jsonpatch[_0x9f75('0x33')](_0x1efc7e,_0x5b8062,!![]);}catch(_0x480414){return BPromise[_0x9f75('0x34')](_0x480414);}return _0x1efc7e['save']();};}function saveUpdates(_0x2e3d6a,_0x3f2e9f){return function(_0x415bef){if(_0x415bef){return _0x415bef[_0x9f75('0x35')](_0x2e3d6a)['then'](function(_0xd7bb6e){return _0xd7bb6e;});}return null;};}function removeEntity(_0x4f4c3e,_0x566fa6){return function(_0x47cdff){if(_0x47cdff){return _0x47cdff[_0x9f75('0x36')]()[_0x9f75('0x22')](function(){var _0xcaabea=_0x47cdff[_0x9f75('0x37')]({'plain':!![]});var _0x367135=_0x9f75('0x38');return db[_0x9f75('0x39')][_0x9f75('0x36')]({'where':{'type':_0x367135,'resourceId':_0xcaabea['id']}})[_0x9f75('0x22')](function(){return _0x47cdff;});})[_0x9f75('0x22')](function(){_0x4f4c3e[_0x9f75('0x2c')](0xcc)[_0x9f75('0x2d')]();});}};}function handleEntityNotFound(_0xc9d417,_0x133bfa){return function(_0x34c078){if(!_0x34c078){_0xc9d417[_0x9f75('0x3a')](0x194);}return _0x34c078;};}function handleError(_0x7335b9,_0xa3ec10){_0xa3ec10=_0xa3ec10||0x1f4;return function(_0x2c4ad5){logger[_0x9f75('0x28')](_0x2c4ad5[_0x9f75('0x3b')]);if(_0x2c4ad5[_0x9f75('0x3c')]){delete _0x2c4ad5[_0x9f75('0x3c')];}_0x7335b9['status'](_0xa3ec10)[_0x9f75('0x3d')](_0x2c4ad5);};}exports[_0x9f75('0x3e')]=function(_0x355b26,_0x5263a8){var _0x4fa935={'include':[{'model':db[_0x9f75('0x3f')],'as':_0x9f75('0x40')}]},_0x3dae5c={},_0x15a019={'count':0x0,'rows':[]};var _0x40da4a=_[_0x9f75('0x41')](db['FaxAccount']['rawAttributes'],function(_0x13fa90){return{'name':_0x13fa90['fieldName'],'type':_0x13fa90[_0x9f75('0x42')][_0x9f75('0x43')]};});_0x3dae5c[_0x9f75('0x44')]=_['map'](_0x40da4a,_0x9f75('0x3c'));_0x3dae5c[_0x9f75('0x45')]=_['keys'](_0x355b26[_0x9f75('0x45')]);_0x3dae5c[_0x9f75('0x46')]=_[_0x9f75('0x47')](_0x3dae5c['model'],_0x3dae5c[_0x9f75('0x45')]);_0x4fa935['attributes']=_[_0x9f75('0x47')](_0x3dae5c[_0x9f75('0x44')],qs[_0x9f75('0x48')](_0x355b26['query'][_0x9f75('0x48')]));_0x4fa935['attributes']=_0x4fa935[_0x9f75('0x49')][_0x9f75('0x4a')]?_0x4fa935['attributes']:_0x3dae5c[_0x9f75('0x44')];if(!_0x355b26['query']['hasOwnProperty'](_0x9f75('0x4b'))){_0x4fa935[_0x9f75('0x30')]=qs['limit'](_0x355b26[_0x9f75('0x45')][_0x9f75('0x30')]);_0x4fa935[_0x9f75('0x2f')]=qs[_0x9f75('0x2f')](_0x355b26[_0x9f75('0x45')][_0x9f75('0x2f')]);}_0x4fa935[_0x9f75('0x4c')]=qs[_0x9f75('0x4d')](_0x355b26[_0x9f75('0x45')]['sort']);_0x4fa935[_0x9f75('0x4e')]=qs[_0x9f75('0x46')](_[_0x9f75('0x4f')](_0x355b26['query'],_0x3dae5c[_0x9f75('0x46')]),_0x40da4a);if(_0x355b26['query'][_0x9f75('0x50')]){_0x4fa935[_0x9f75('0x4e')]=_['merge'](_0x4fa935[_0x9f75('0x4e')],{'$or':_[_0x9f75('0x41')](_0x40da4a,function(_0x15c675){if(_0x15c675['type']!==_0x9f75('0x51')){var _0x320d59={};_0x320d59[_0x15c675[_0x9f75('0x3c')]]={'$like':'%'+_0x355b26['query'][_0x9f75('0x50')]+'%'};return _0x320d59;}})});}_0x4fa935=_['merge']({},_0x4fa935,_0x355b26[_0x9f75('0x52')]);var _0x33d7c6={'where':_0x4fa935['where']};return db[_0x9f75('0x53')][_0x9f75('0x2e')](_0x33d7c6)[_0x9f75('0x22')](function(_0x5e09fd){_0x15a019[_0x9f75('0x2e')]=_0x5e09fd;if(_0x355b26[_0x9f75('0x45')][_0x9f75('0x54')]){_0x4fa935[_0x9f75('0x55')]=[{'all':!![]}];}return db[_0x9f75('0x53')][_0x9f75('0x56')](_0x4fa935);})[_0x9f75('0x22')](function(_0x43be0a){_0x15a019[_0x9f75('0x57')]=_0x43be0a;return _0x15a019;})[_0x9f75('0x22')](respondWithFilteredResult(_0x5263a8,_0x4fa935))['catch'](handleError(_0x5263a8,null));};exports[_0x9f75('0x58')]=function(_0x15d2aa,_0x2a1f8d){var _0x449254={'raw':![],'where':{'id':_0x15d2aa[_0x9f75('0x59')]['id']},'include':[{'model':db[_0x9f75('0x3f')],'as':_0x9f75('0x40')}]},_0x5515af={};_0x5515af['model']=_[_0x9f75('0x5a')](db[_0x9f75('0x53')]['rawAttributes']);_0x5515af[_0x9f75('0x45')]=_[_0x9f75('0x5a')](_0x15d2aa['query']);_0x5515af['filters']=_[_0x9f75('0x47')](_0x5515af[_0x9f75('0x44')],_0x5515af[_0x9f75('0x45')]);_0x449254['attributes']=_[_0x9f75('0x47')](_0x5515af[_0x9f75('0x44')],qs['fields'](_0x15d2aa['query'][_0x9f75('0x48')]));_0x449254[_0x9f75('0x49')]=_0x449254[_0x9f75('0x49')][_0x9f75('0x4a')]?_0x449254[_0x9f75('0x49')]:_0x5515af[_0x9f75('0x44')];if(_0x15d2aa[_0x9f75('0x45')][_0x9f75('0x54')]){_0x449254[_0x9f75('0x55')]=[{'all':!![]}];}_0x449254=_[_0x9f75('0x5b')]({},_0x449254,_0x15d2aa[_0x9f75('0x52')]);return db[_0x9f75('0x53')][_0x9f75('0x5c')](_0x449254)[_0x9f75('0x22')](handleEntityNotFound(_0x2a1f8d,null))[_0x9f75('0x22')](respondWithResult(_0x2a1f8d,null))['catch'](handleError(_0x2a1f8d,null));};exports[_0x9f75('0x5d')]=function(_0x37404c,_0x49143b){return db[_0x9f75('0x53')][_0x9f75('0x5d')](_0x37404c[_0x9f75('0x5e')],{})[_0x9f75('0x22')](function(_0xceb56e){var _0xe4452=_0x37404c['user'][_0x9f75('0x37')]({'plain':!![]});if(!_0xe4452)throw new Error(_0x9f75('0x5f'));if(_0xe4452[_0x9f75('0x60')]===_0x9f75('0x61')){var _0x448e43=_0xceb56e[_0x9f75('0x37')]({'plain':!![]});var _0x17bf8f=_0x9f75('0x38');return db[_0x9f75('0x62')][_0x9f75('0x5c')]({'where':{'name':_0x17bf8f,'userProfileId':_0xe4452['userProfileId']},'raw':!![]})[_0x9f75('0x22')](function(_0xc974c8){if(_0xc974c8&&_0xc974c8[_0x9f75('0x63')]===0x0){return db[_0x9f75('0x39')][_0x9f75('0x5d')]({'name':_0x448e43[_0x9f75('0x3c')],'resourceId':_0x448e43['id'],'type':_0xc974c8[_0x9f75('0x3c')],'sectionId':_0xc974c8['id']},{})[_0x9f75('0x22')](function(){return _0xceb56e;});}else{return _0xceb56e;}})[_0x9f75('0x2b')](function(_0x291dc0){logger[_0x9f75('0x28')](_0x9f75('0x64'),_0x291dc0);throw _0x291dc0;});}return _0xceb56e;})[_0x9f75('0x22')](respondWithResult(_0x49143b,0xc9))[_0x9f75('0x2b')](handleError(_0x49143b,null));};exports[_0x9f75('0x35')]=function(_0x43c7ac,_0x38f337){if(_0x43c7ac['body']['id']){delete _0x43c7ac[_0x9f75('0x5e')]['id'];}return db[_0x9f75('0x53')][_0x9f75('0x5c')]({'where':{'id':_0x43c7ac[_0x9f75('0x59')]['id']},'include':[{'model':db[_0x9f75('0x3f')],'as':_0x9f75('0x40')}]})['then'](handleEntityNotFound(_0x38f337,null))[_0x9f75('0x22')](saveUpdates(_0x43c7ac[_0x9f75('0x5e')],null))[_0x9f75('0x22')](respondWithResult(_0x38f337,null))[_0x9f75('0x2b')](handleError(_0x38f337,null));};exports[_0x9f75('0x36')]=function(_0x15a78d,_0x45dac7){return db[_0x9f75('0x53')][_0x9f75('0x5c')]({'where':{'id':_0x15a78d[_0x9f75('0x59')]['id']}})['then'](handleEntityNotFound(_0x45dac7,null))[_0x9f75('0x22')](removeEntity(_0x45dac7,null))[_0x9f75('0x2b')](handleError(_0x45dac7,null));};exports[_0x9f75('0x65')]=function(_0x59e84b,_0x43e0bc){return db['FaxAccount'][_0x9f75('0x65')]()[_0x9f75('0x22')](respondWithResult(_0x43e0bc,null))[_0x9f75('0x2b')](handleError(_0x43e0bc,null));};exports['addDisposition']=function(_0x3e51d7,_0x5d7546,_0x539fcd){if(_0x3e51d7[_0x9f75('0x5e')]['id']){delete _0x3e51d7[_0x9f75('0x5e')]['id'];}return db[_0x9f75('0x53')][_0x9f75('0x5c')]({'where':{'id':_0x3e51d7[_0x9f75('0x59')]['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x5d7546,null))[_0x9f75('0x22')](function(_0x5da368){if(_0x5da368){_0x3e51d7[_0x9f75('0x5e')]['FaxAccountId']=_0x5da368['id'];return db[_0x9f75('0x66')][_0x9f75('0x5d')](_0x3e51d7[_0x9f75('0x5e')]);}})[_0x9f75('0x22')](respondWithResult(_0x5d7546,null))['catch'](handleError(_0x5d7546,null));};exports['getDispositions']=function(_0x37c569,_0x54ee73,_0xe70149){var _0x3ebafb={'raw':![],'where':{}};var _0x3e5fa5={};var _0x27b470={'count':0x0,'rows':[]};return db['FaxAccount'][_0x9f75('0x67')]({'where':{'id':_0x37c569['params']['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x54ee73,null))[_0x9f75('0x22')](function(_0x27947e){if(_0x27947e){_0x3e5fa5[_0x9f75('0x44')]=_['keys'](db[_0x9f75('0x66')][_0x9f75('0x68')]);_0x3e5fa5[_0x9f75('0x45')]=_[_0x9f75('0x5a')](_0x37c569['query']);_0x3e5fa5['filters']=_[_0x9f75('0x47')](_0x3e5fa5[_0x9f75('0x44')],_0x3e5fa5[_0x9f75('0x45')]);_0x3ebafb['attributes']=_[_0x9f75('0x47')](_0x3e5fa5[_0x9f75('0x44')],qs[_0x9f75('0x48')](_0x37c569[_0x9f75('0x45')][_0x9f75('0x48')]));_0x3ebafb[_0x9f75('0x49')]=_0x3ebafb['attributes'][_0x9f75('0x4a')]?_0x3ebafb[_0x9f75('0x49')]:_0x3e5fa5[_0x9f75('0x44')];if(!_0x37c569[_0x9f75('0x45')][_0x9f75('0x69')]('nolimit')){_0x3ebafb[_0x9f75('0x30')]=qs['limit'](_0x37c569[_0x9f75('0x45')][_0x9f75('0x30')]);_0x3ebafb['offset']=qs[_0x9f75('0x2f')](_0x37c569[_0x9f75('0x45')][_0x9f75('0x2f')]);}_0x3ebafb[_0x9f75('0x4c')]=qs[_0x9f75('0x4d')](_0x37c569['query'][_0x9f75('0x4d')]);_0x3ebafb['where']=qs['filters'](_['pick'](_0x37c569[_0x9f75('0x45')],_0x3e5fa5[_0x9f75('0x46')]));_0x3ebafb['where'][_0x9f75('0x6a')]=_0x27947e['id'];if(_0x37c569['query']['filter']){_0x3ebafb[_0x9f75('0x4e')]=_[_0x9f75('0x5b')](_0x3ebafb[_0x9f75('0x4e')],{'$or':_['map'](_0x3ebafb[_0x9f75('0x49')],function(_0x5b916c){var _0x1d9202={};_0x1d9202[_0x5b916c]={'$like':'%'+_0x37c569[_0x9f75('0x45')][_0x9f75('0x50')]+'%'};return _0x1d9202;})});}_0x3ebafb=_['merge']({},_0x3ebafb,_0x37c569['options']);return db[_0x9f75('0x66')][_0x9f75('0x2e')]({'where':_0x3ebafb['where']})[_0x9f75('0x22')](function(_0x3702b2){_0x27b470[_0x9f75('0x2e')]=_0x3702b2;if(_0x37c569[_0x9f75('0x45')][_0x9f75('0x54')]){_0x3ebafb[_0x9f75('0x55')]=[{'all':!![]}];}return db[_0x9f75('0x66')]['findAll'](_0x3ebafb);})[_0x9f75('0x22')](function(_0x34f4b3){_0x27b470[_0x9f75('0x57')]=_0x34f4b3;return _0x27b470;});}})[_0x9f75('0x22')](respondWithFilteredResult(_0x54ee73,_0x3ebafb))[_0x9f75('0x2b')](handleError(_0x54ee73,null));};exports[_0x9f75('0x6b')]=function(_0x4c0939,_0x51054e,_0x45d142){return db[_0x9f75('0x53')][_0x9f75('0x5c')]({'where':{'id':_0x4c0939[_0x9f75('0x59')]['id']}})['then'](handleEntityNotFound(_0x51054e,null))[_0x9f75('0x22')](function(_0x8d3a49){if(_0x8d3a49){return _0x8d3a49[_0x9f75('0x6b')](_0x4c0939[_0x9f75('0x45')][_0x9f75('0x6c')]);}})[_0x9f75('0x22')](respondWithStatusCode(_0x51054e,null))[_0x9f75('0x2b')](handleError(_0x51054e,null));};exports['addAnswer']=function(_0x436720,_0x1eae7f,_0x3e81bb){if(_0x436720[_0x9f75('0x5e')]['id']){delete _0x436720[_0x9f75('0x5e')]['id'];}return db[_0x9f75('0x53')]['find']({'where':{'id':_0x436720[_0x9f75('0x59')]['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x1eae7f,null))[_0x9f75('0x22')](function(_0xaa8b4c){if(_0xaa8b4c){_0x436720['body'][_0x9f75('0x6a')]=_0xaa8b4c['id'];return db['CannedAnswer']['create'](_0x436720['body']);}})[_0x9f75('0x22')](respondWithResult(_0x1eae7f,null))[_0x9f75('0x2b')](handleError(_0x1eae7f,null));};exports[_0x9f75('0x6d')]=function(_0x1f8e67,_0x426803,_0x7d9f1e){var _0x33e475={'raw':![],'where':{}};var _0x130b97={};var _0x5ce4d4={'count':0x0,'rows':[]};return db['FaxAccount'][_0x9f75('0x67')]({'where':{'id':_0x1f8e67['params']['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x426803,null))['then'](function(_0x218ef9){if(_0x218ef9){_0x130b97['model']=_[_0x9f75('0x5a')](db[_0x9f75('0x6e')][_0x9f75('0x68')]);_0x130b97[_0x9f75('0x45')]=_[_0x9f75('0x5a')](_0x1f8e67[_0x9f75('0x45')]);_0x130b97[_0x9f75('0x46')]=_['intersection'](_0x130b97[_0x9f75('0x44')],_0x130b97[_0x9f75('0x45')]);_0x33e475[_0x9f75('0x49')]=_[_0x9f75('0x47')](_0x130b97[_0x9f75('0x44')],qs['fields'](_0x1f8e67[_0x9f75('0x45')][_0x9f75('0x48')]));_0x33e475[_0x9f75('0x49')]=_0x33e475[_0x9f75('0x49')][_0x9f75('0x4a')]?_0x33e475[_0x9f75('0x49')]:_0x130b97['model'];if(!_0x1f8e67['query'][_0x9f75('0x69')]('nolimit')){_0x33e475[_0x9f75('0x30')]=qs[_0x9f75('0x30')](_0x1f8e67[_0x9f75('0x45')][_0x9f75('0x30')]);_0x33e475[_0x9f75('0x2f')]=qs[_0x9f75('0x2f')](_0x1f8e67[_0x9f75('0x45')][_0x9f75('0x2f')]);}_0x33e475[_0x9f75('0x4c')]=qs['sort'](_0x1f8e67[_0x9f75('0x45')][_0x9f75('0x4d')]);_0x33e475[_0x9f75('0x4e')]=qs[_0x9f75('0x46')](_['pick'](_0x1f8e67[_0x9f75('0x45')],_0x130b97[_0x9f75('0x46')]));_0x33e475[_0x9f75('0x4e')][_0x9f75('0x6a')]=_0x218ef9['id'];if(_0x1f8e67[_0x9f75('0x45')]['filter']){_0x33e475['where']=_[_0x9f75('0x5b')](_0x33e475['where'],{'$or':_['map'](_0x33e475[_0x9f75('0x49')],function(_0x42851a){var _0x3f4b65={};_0x3f4b65[_0x42851a]={'$like':'%'+_0x1f8e67['query'][_0x9f75('0x50')]+'%'};return _0x3f4b65;})});}_0x33e475=_[_0x9f75('0x5b')]({},_0x33e475,_0x1f8e67[_0x9f75('0x52')]);return db[_0x9f75('0x6e')][_0x9f75('0x2e')]({'where':_0x33e475[_0x9f75('0x4e')]})[_0x9f75('0x22')](function(_0x4e5b89){_0x5ce4d4['count']=_0x4e5b89;if(_0x1f8e67['query']['includeAll']){_0x33e475['include']=[{'all':!![]}];}return db['CannedAnswer'][_0x9f75('0x56')](_0x33e475);})[_0x9f75('0x22')](function(_0x1e44f5){_0x5ce4d4[_0x9f75('0x57')]=_0x1e44f5;return _0x5ce4d4;});}})['then'](respondWithFilteredResult(_0x426803,_0x33e475))['catch'](handleError(_0x426803,null));};exports[_0x9f75('0x6f')]=function(_0xd18366,_0x2f26db,_0x258543){return db[_0x9f75('0x53')][_0x9f75('0x5c')]({'where':{'id':_0xd18366[_0x9f75('0x59')]['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x2f26db,null))['then'](function(_0x141a56){if(_0x141a56){return _0x141a56[_0x9f75('0x6f')](_0xd18366[_0x9f75('0x45')][_0x9f75('0x6c')]);}})['then'](respondWithStatusCode(_0x2f26db,null))[_0x9f75('0x2b')](handleError(_0x2f26db,null));};exports[_0x9f75('0x70')]=function(_0x2807b6,_0x50b4d0,_0x143c7d){return db[_0x9f75('0x71')][_0x9f75('0x5c')]({'where':{'id':_0x2807b6[_0x9f75('0x59')]['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x50b4d0,null))[_0x9f75('0x22')](function(_0x1c4a15){if(_0x1c4a15){return _0x1c4a15[_0x9f75('0x70')](_0x2807b6[_0x9f75('0x5e')][_0x9f75('0x6c')],_['omit'](_0x2807b6['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x50b4d0,null))[_0x9f75('0x2b')](handleError(_0x50b4d0,null));};exports[_0x9f75('0x72')]=function(_0x9640a1,_0xbde106,_0x400860){var _0x4d5b6d={'raw':![],'where':{}};var _0x32b109={};var _0x5dc9bf={'count':0x0,'rows':[]};return db[_0x9f75('0x53')][_0x9f75('0x67')]({'where':{'id':_0x9640a1[_0x9f75('0x59')]['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0xbde106,null))[_0x9f75('0x22')](function(_0x47fc49){if(_0x47fc49){_0x32b109[_0x9f75('0x44')]=_[_0x9f75('0x5a')](db[_0x9f75('0x71')][_0x9f75('0x68')]);_0x32b109['query']=_[_0x9f75('0x5a')](_0x9640a1['query']);_0x32b109[_0x9f75('0x46')]=_[_0x9f75('0x47')](_0x32b109['model'],_0x32b109[_0x9f75('0x45')]);_0x4d5b6d['attributes']=_['intersection'](_0x32b109[_0x9f75('0x44')],qs['fields'](_0x9640a1[_0x9f75('0x45')]['fields']));_0x4d5b6d[_0x9f75('0x49')]=_0x4d5b6d['attributes'][_0x9f75('0x4a')]?_0x4d5b6d[_0x9f75('0x49')]:_0x32b109[_0x9f75('0x44')];if(!_0x9640a1[_0x9f75('0x45')]['hasOwnProperty'](_0x9f75('0x4b'))){_0x4d5b6d[_0x9f75('0x30')]=qs['limit'](_0x9640a1[_0x9f75('0x45')][_0x9f75('0x30')]);_0x4d5b6d['offset']=qs[_0x9f75('0x2f')](_0x9640a1[_0x9f75('0x45')][_0x9f75('0x2f')]);}_0x4d5b6d[_0x9f75('0x4c')]=qs[_0x9f75('0x4d')](_0x9640a1['query'][_0x9f75('0x4d')]);_0x4d5b6d[_0x9f75('0x4e')]=qs[_0x9f75('0x46')](_[_0x9f75('0x4f')](_0x9640a1[_0x9f75('0x45')],_0x32b109['filters']));_0x4d5b6d['where'][_0x9f75('0x6a')]=_0x47fc49['id'];if(_0x9640a1['query'][_0x9f75('0x50')]){_0x4d5b6d[_0x9f75('0x4e')]=_[_0x9f75('0x5b')](_0x4d5b6d['where'],{'$or':_[_0x9f75('0x41')](_0x4d5b6d[_0x9f75('0x49')],function(_0x4f5b12){var _0x6474ce={};_0x6474ce[_0x4f5b12]={'$like':'%'+_0x9640a1[_0x9f75('0x45')]['filter']+'%'};return _0x6474ce;})});}_0x4d5b6d=_[_0x9f75('0x5b')]({},_0x4d5b6d,_0x9640a1['options']);return db[_0x9f75('0x71')][_0x9f75('0x2e')]({'where':_0x4d5b6d['where']})[_0x9f75('0x22')](function(_0x549a3d){_0x5dc9bf['count']=_0x549a3d;if(_0x9640a1[_0x9f75('0x45')][_0x9f75('0x54')]){_0x4d5b6d[_0x9f75('0x55')]=[{'model':db[_0x9f75('0x73')],'as':'Contact','required':![]},{'model':db[_0x9f75('0x74')],'as':_0x9f75('0x75'),'attributes':[_0x9f75('0x3c'),_0x9f75('0x76'),'internal'],'required':![]},{'model':db[_0x9f75('0x77')],'as':'Tags','attributes':['id',_0x9f75('0x3c'),'color'],'where':_0x9640a1['query']['tag']?{'id':_0x9640a1[_0x9f75('0x45')]['tag']}:undefined,'required':_0x9640a1['query'][_0x9f75('0x78')]?!![]:![]}];}return db[_0x9f75('0x71')]['findAll'](_0x4d5b6d);})[_0x9f75('0x22')](function(_0x17568c){_0x5dc9bf[_0x9f75('0x57')]=_0x17568c;return _0x5dc9bf;});}})['then'](respondWithFilteredResult(_0xbde106,_0x4d5b6d))['catch'](handleError(_0xbde106,null));};exports[_0x9f75('0x79')]=function(_0x1bd8b8,_0x5cfb06,_0x164059){return db[_0x9f75('0x53')][_0x9f75('0x67')]({'where':{'id':_0x1bd8b8[_0x9f75('0x59')]['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x5cfb06,null))['then'](function(_0x4ac710){if(_0x4ac710){return db[_0x9f75('0x7a')][_0x9f75('0x7b')](function(_0x1177e8){return db[_0x9f75('0x7c')][_0x9f75('0x36')]({'where':{'FaxAccountId':_0x1bd8b8[_0x9f75('0x59')]['id']},'transaction':_0x1177e8})['then'](function(_0x47f8e0){var _0x22115c=_[_0x9f75('0x41')](_0x1bd8b8[_0x9f75('0x5e')],function(_0x52dd19){_0x52dd19[_0x9f75('0x6a')]=_0x1bd8b8[_0x9f75('0x59')]['id'];return _0x52dd19;});return db[_0x9f75('0x7c')][_0x9f75('0x7d')](_0x22115c,{'transaction':_0x1177e8});});})[_0x9f75('0x22')](function(){return db[_0x9f75('0x7c')][_0x9f75('0x7e')]({'where':{'FaxAccountId':_0x1bd8b8[_0x9f75('0x59')]['id']},'order':_0x9f75('0x7f')});});}})['then'](respondWithResult(_0x5cfb06,null))[_0x9f75('0x2b')](handleError(_0x5cfb06,null));};exports[_0x9f75('0x80')]=function(_0x53a8c8,_0x558718,_0x1af77e){var _0x468c54={};var _0x3af693={};var _0x3c34d3;var _0x14a1aa;return db[_0x9f75('0x53')][_0x9f75('0x67')]({'where':{'id':_0x53a8c8[_0x9f75('0x59')]['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x558718,null))[_0x9f75('0x22')](function(_0x3791e5){if(_0x3791e5){_0x3c34d3=_0x3791e5;_0x3af693['model']=_[_0x9f75('0x5a')](db[_0x9f75('0x7c')]['rawAttributes']);_0x3af693[_0x9f75('0x45')]=_[_0x9f75('0x5a')](_0x53a8c8['query']);_0x3af693[_0x9f75('0x46')]=_[_0x9f75('0x47')](_0x3af693[_0x9f75('0x44')],_0x3af693['query']);_0x468c54[_0x9f75('0x49')]=_[_0x9f75('0x47')](_0x3af693[_0x9f75('0x44')],qs['fields'](_0x53a8c8[_0x9f75('0x45')][_0x9f75('0x48')]));_0x468c54[_0x9f75('0x49')]=_0x468c54['attributes'][_0x9f75('0x4a')]?_0x468c54['attributes']:_0x3af693['model'];_0x468c54[_0x9f75('0x4c')]=qs[_0x9f75('0x4d')](_0x53a8c8[_0x9f75('0x45')][_0x9f75('0x4d')]);_0x468c54[_0x9f75('0x4e')]=qs['filters'](_[_0x9f75('0x4f')](_0x53a8c8['query'],_0x3af693['filters']));if(_0x53a8c8['query'][_0x9f75('0x50')]){_0x468c54[_0x9f75('0x4e')]=_[_0x9f75('0x5b')](_0x468c54[_0x9f75('0x4e')],{'$or':_[_0x9f75('0x41')](_0x468c54[_0x9f75('0x49')],function(_0x4de69b){var _0x35e240={};_0x35e240[_0x4de69b]={'$like':'%'+_0x53a8c8[_0x9f75('0x45')][_0x9f75('0x50')]+'%'};return _0x35e240;})});}_0x468c54=_[_0x9f75('0x5b')]({},_0x468c54,_0x53a8c8[_0x9f75('0x52')]);return _0x3c34d3[_0x9f75('0x80')](_0x468c54);}})['then'](function(_0x367318){if(_0x367318){_0x14a1aa=_0x367318[_0x9f75('0x4a')];if(!_0x53a8c8[_0x9f75('0x45')][_0x9f75('0x69')]('nolimit')){_0x468c54[_0x9f75('0x30')]=qs['limit'](_0x53a8c8['query']['limit']);_0x468c54['offset']=qs[_0x9f75('0x2f')](_0x53a8c8[_0x9f75('0x45')][_0x9f75('0x2f')]);}return _0x3c34d3[_0x9f75('0x80')](_0x468c54);}})['then'](function(_0x4102ba){if(_0x4102ba){return _0x4102ba?{'count':_0x14a1aa,'rows':_0x4102ba}:null;}})[_0x9f75('0x22')](respondWithResult(_0x558718,null))[_0x9f75('0x2b')](handleError(_0x558718,null));};function Extension(_0x271083,_0x410fc1,_0x3f2fd3,_0x492f73){this['context']='from-voip-provider';this[_0x9f75('0x81')]=_0x271083['localstationid'];this[_0x9f75('0x82')]=_0x492f73;this['type']=_0x9f75('0x83');this[_0x9f75('0x84')]='Fax\x20Extension';this['FaxAccountId']=_0x271083['id'];this[_0x9f75('0x7f')]=_0x410fc1;this[_0x9f75('0x85')]=_0x3f2fd3;}function createExtensionsReciveFax(_0x5cbf77){var _0x4fd943=0x1;var _0x5c3c70=[];_0x5c3c70[_0x9f75('0x86')](new Extension(_0x5cbf77,_0x4fd943,'',_0x9f75('0x87')));_0x4fd943+=0x1;_0x5c3c70['push'](new Extension(_0x5cbf77,_0x4fd943,_0x9f75('0x88'),'Set'));_0x4fd943+=0x1;for(var _0x4ebc01 in _0x5cbf77){if(_0x5cbf77['hasOwnProperty'](_0x4ebc01)&&(_0x4ebc01==='ecm'||_0x4ebc01===_0x9f75('0x89')||_0x4ebc01==='gateway'||_0x4ebc01===_0x9f75('0x8a')||_0x4ebc01===_0x9f75('0x8b')||_0x4ebc01===_0x9f75('0x8c')||_0x4ebc01===_0x9f75('0x8d')||_0x4ebc01===_0x9f75('0x8e')||_0x4ebc01===_0x9f75('0x8f'))){_0x5c3c70[_0x9f75('0x86')](new Extension(_0x5cbf77,_0x4fd943,_0x9f75('0x90')+_0x4ebc01+')='+_0x5cbf77[_0x4ebc01],'Set'));_0x4fd943+=0x1;}}_0x5c3c70['push'](new Extension(_0x5cbf77,_0x4fd943,'6',_0x9f75('0x91')));_0x4fd943+=0x1;_0x5c3c70['push'](new Extension(_0x5cbf77,_0x4fd943,_0x9f75('0x92'),_0x9f75('0x93')));_0x4fd943=0x0;return _0x5c3c70;}exports['addAccountApplications']=function(_0x5dafdb,_0x4ae279,_0x175438){var _0x37a8d4;return db[_0x9f75('0x7a')][_0x9f75('0x7b')](function(_0x35bc5f){return db['FaxAccount'][_0x9f75('0x5d')](_0x5dafdb[_0x9f75('0x5e')],{'transaction':_0x35bc5f})[_0x9f75('0x22')](function(_0x55ed79){_0x37a8d4=_0x55ed79['get']({'plain':!![]});return db['VoiceExtension']['bulkCreate'](createExtensionsReciveFax(_0x37a8d4),{'transaction':_0x35bc5f});});})['then'](function(){return _0x37a8d4;})[_0x9f75('0x22')](respondWithResult(_0x4ae279,null))['catch'](handleError(_0x4ae279,null));};exports[_0x9f75('0x94')]=function(_0x2d4754,_0x539f2a,_0x574057){var _0x3c1ef0;return db[_0x9f75('0x7a')][_0x9f75('0x7b')](function(_0x3caf01){return db[_0x9f75('0x53')][_0x9f75('0x35')](_0x2d4754[_0x9f75('0x5e')],{'where':{'id':_0x2d4754['body']['id']},'transaction':_0x3caf01})[_0x9f75('0x22')](function(_0x3a2685){return db[_0x9f75('0x95')][_0x9f75('0x36')]({'where':{'FaxAccountId':_0x2d4754[_0x9f75('0x5e')]['id']},'transaction':_0x3caf01})[_0x9f75('0x22')](function(_0x156b12){return db[_0x9f75('0x95')][_0x9f75('0x7d')](createExtensionsReciveFax(_['omit'](_0x2d4754[_0x9f75('0x5e')],[_0x9f75('0x96'),_0x9f75('0x43'),'createdAt',_0x9f75('0x97'),'TrunkId',_0x9f75('0x98')])),{'transaction':_0x3caf01});});});})['then'](function(){return db['FaxAccount'][_0x9f75('0x99')](_0x2d4754['body']['id']);})[_0x9f75('0x22')](respondWithResult(_0x539f2a,null))[_0x9f75('0x2b')](handleError(_0x539f2a,null));};exports[_0x9f75('0x9a')]=function(_0x29612d,_0x2b1a5a,_0x5a5501){var _0x464979={'raw':!![],'where':{}};var _0x3d6a38={};var _0x5cfb34={'count':0x0,'rows':[]};return db[_0x9f75('0x53')][_0x9f75('0x67')]({'where':{'id':_0x29612d['params']['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x2b1a5a,null))['then'](function(_0x3dbaa0){if(_0x3dbaa0){_0x3d6a38[_0x9f75('0x44')]=_[_0x9f75('0x5a')](db[_0x9f75('0x9b')][_0x9f75('0x68')]);_0x3d6a38[_0x9f75('0x45')]=_[_0x9f75('0x5a')](_0x29612d[_0x9f75('0x45')]);_0x3d6a38[_0x9f75('0x46')]=_[_0x9f75('0x47')](_0x3d6a38['model'],_0x3d6a38[_0x9f75('0x45')]);_0x464979['attributes']=_['intersection'](_0x3d6a38[_0x9f75('0x44')],qs[_0x9f75('0x48')](_0x29612d[_0x9f75('0x45')][_0x9f75('0x48')]));_0x464979[_0x9f75('0x49')]=_0x464979[_0x9f75('0x49')][_0x9f75('0x4a')]?_0x464979[_0x9f75('0x49')]:_0x3d6a38[_0x9f75('0x44')];if(!_0x29612d[_0x9f75('0x45')][_0x9f75('0x69')](_0x9f75('0x4b'))){_0x464979['limit']=qs[_0x9f75('0x30')](_0x29612d[_0x9f75('0x45')][_0x9f75('0x30')]);_0x464979[_0x9f75('0x2f')]=qs[_0x9f75('0x2f')](_0x29612d['query']['offset']);}_0x464979[_0x9f75('0x4c')]=qs[_0x9f75('0x4d')](_0x29612d[_0x9f75('0x45')][_0x9f75('0x4d')]);_0x464979[_0x9f75('0x4e')]=qs[_0x9f75('0x46')](_[_0x9f75('0x4f')](_0x29612d[_0x9f75('0x45')],_0x3d6a38[_0x9f75('0x46')]));_0x464979[_0x9f75('0x4e')]['FaxAccountId']=_0x3dbaa0['id'];if(_0x29612d[_0x9f75('0x45')]['filter']){_0x464979['where']=_['merge'](_0x464979[_0x9f75('0x4e')],{'$or':_['map'](_0x464979[_0x9f75('0x49')],function(_0x206c62){var _0x162f8a={};_0x162f8a[_0x206c62]={'$like':'%'+_0x29612d[_0x9f75('0x45')][_0x9f75('0x50')]+'%'};return _0x162f8a;})});}if(_0x29612d[_0x9f75('0x45')][_0x9f75('0x9c')]){var _0x3dad64=_0x29612d[_0x9f75('0x45')][_0x9f75('0x9c')][_0x9f75('0x9d')](',');var _0x571ce4={};_0x571ce4[_0x3dad64[0x0]]={'$gte':moment(_0x3dad64[0x1])[_0x9f75('0x9e')](_0x9f75('0x9f'))};_0x464979[_0x9f75('0x4e')]=_[_0x9f75('0x5b')](_0x464979['where'],_0x571ce4);}_0x464979=_[_0x9f75('0x5b')]({},_0x464979,_0x29612d[_0x9f75('0x52')]);return db[_0x9f75('0x9b')]['count']({'where':_0x464979[_0x9f75('0x4e')]})['then'](function(_0x4496d8){_0x5cfb34[_0x9f75('0x2e')]=_0x4496d8;if(_0x29612d['query'][_0x9f75('0x54')]){_0x464979[_0x9f75('0x55')]=[{'all':!![]}];}return db[_0x9f75('0x9b')][_0x9f75('0x56')](_0x464979);})[_0x9f75('0x22')](function(_0x1a3401){_0x5cfb34[_0x9f75('0x57')]=_0x1a3401;return _0x5cfb34;});}})[_0x9f75('0x22')](respondWithFilteredResult(_0x2b1a5a,_0x464979))[_0x9f75('0x2b')](handleError(_0x2b1a5a,null));};exports['send']=function(_0x5e3713,_0x19ccb3,_0x183565){var _0x27dbcd,_0x2818d6={},_0x12c5ea;if(_0x5e3713[_0x9f75('0x5e')]['to']){_0x12c5ea=_0x5e3713[_0x9f75('0x5e')]['to'][0x0];}return db['FaxAccount'][_0x9f75('0x5c')]({'where':{'id':_0x5e3713[_0x9f75('0x59')]['id']},'include':[{'model':db[_0x9f75('0xa0')],'as':'List','include':[{'model':db[_0x9f75('0x73')],'as':'Contacts','where':{'fax':_0x12c5ea},'limit':0x1,'order':[['updatedAt',_0x9f75('0xa1')]]}]}]})['then'](handleEntityNotFound(_0x19ccb3,null))['then'](function(_0x583958){_0x27dbcd=_0x583958;if(_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')]&&_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')][_0x9f75('0x4a')]){for(var _0x54a8cf=0x0;_0x54a8cf<_0x5e3713['body'][_0x9f75('0xa2')]['length'];_0x54a8cf+=0x1){_0x5e3713[_0x9f75('0x5e')]['attachments'][_0x54a8cf]={'filename':_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')][_0x54a8cf]['name'],'id':_0x5e3713['body'][_0x9f75('0xa2')][_0x54a8cf]['id'],'path':path['join'](config[_0x9f75('0xa3')],'server/files/attachments',_0x5e3713['body'][_0x9f75('0xa2')][_0x54a8cf][_0x9f75('0xa4')])};}}return respondWithRpcPromise(_0x9f75('0xa5'),'CheckAfterSend',{'FaxAccountId':_[_0x9f75('0xa6')](_0x5e3713[_0x9f75('0x59')]['id'])?undefined:_0x5e3713[_0x9f75('0x59')]['id'],'path':_[_0x9f75('0xa6')](_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')][0x0]['path'])?undefined:_0x5e3713['body'][_0x9f75('0xa2')][0x0]['path'],'fax':_[_0x9f75('0xa6')](_0x5e3713[_0x9f75('0x5e')]['to'][0x0])?undefined:_0x5e3713['body']['to'][0x0]},client9002);})[_0x9f75('0x22')](function(){if(_0x27dbcd){if(_[_0x9f75('0xa6')](_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa7')])){_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa7')]=util['format']('\x22%s\x22\x20<%s>',_0x27dbcd['name'],_0x27dbcd[_0x9f75('0xa8')]);}if(_0x27dbcd[_0x9f75('0xa9')]){if(_0x27dbcd[_0x9f75('0xa9')]['Contacts'][_0x9f75('0x4a')]){return _0x27dbcd[_0x9f75('0xa9')][_0x9f75('0xaa')][0x0];}else{return db[_0x9f75('0x73')][_0x9f75('0x5d')](_[_0x9f75('0x19')](_0x5e3713[_0x9f75('0x5e')],{'firstName':_0x5e3713[_0x9f75('0x5e')]['to'][0x0],'phone':_0x5e3713['body']['to'][0x0],'fax':_0x5e3713[_0x9f75('0x5e')]['to'][0x0],'ListId':_0x27dbcd[_0x9f75('0x98')]}));}}else{throw new Error(_0x9f75('0xab'));}}else{throw new Error(_0x9f75('0xac'));}})[_0x9f75('0x22')](function(_0xbefeca){if(_0xbefeca){return db[_0x9f75('0x71')]['find']({'where':{'ContactId':_0xbefeca['id'],'closed':![],'FaxAccountId':_0x27dbcd['id']}})[_0x9f75('0x22')](function(_0x47954b){if(_0x47954b){return[_0x47954b,![]];}return db['FaxInteraction'][_0x9f75('0x5d')]({'UserId':_0x5e3713[_0x9f75('0x61')]['id'],'ContactId':_0xbefeca['id'],'FaxAccountId':_0x27dbcd['id'],'fax':_0x5e3713[_0x9f75('0x5e')]['to'][0x0],'firstMsgDirection':_0x9f75('0xad'),'Messages':[_[_0x9f75('0x5b')](_0x5e3713[_0x9f75('0x5e')],{'read':![],'body':_0x5e3713[_0x9f75('0x5e')]['attachments'][0x0][_0x9f75('0xae')],'FaxAccountId':_0x27dbcd['id'],'UserId':_0x5e3713[_0x9f75('0x61')]['id'],'ContactId':_0xbefeca['id'],'AttachmentId':_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')][0x0]['id']})]},{'include':[{'model':db[_0x9f75('0x9b')],'as':_0x9f75('0xaf')}]})[_0x9f75('0x22')](function(_0x147338){return[_0x147338,!![]];});});}else{throw new Error(_0x9f75('0xb0'));}})[_0x9f75('0xb1')](function(_0x46d061,_0x12ffa1){if(_0x12ffa1){return _0x46d061;}return db[_0x9f75('0x9b')][_0x9f75('0x5d')]({'direction':_0x9f75('0xad'),'read':![],'body':_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')][0x0][_0x9f75('0xae')],'FaxAccountId':_0x27dbcd['id'],'FaxInteractionId':_0x46d061['id'],'UserId':_0x5e3713[_0x9f75('0x61')]['id'],'ContactId':_0x46d061[_0x9f75('0xb2')],'AttachmentId':_0x5e3713['body'][_0x9f75('0xa2')][0x0]['id']})[_0x9f75('0x22')](function(_0x57be03){_0x46d061[_0x9f75('0xb3')]['Messages']=[];_0x46d061['dataValues'][_0x9f75('0xaf')]['push'](_0x57be03['dataValues']);return _0x46d061;});})['then'](function(_0x69c9c9){respondWithRpcPromise('SendFax','SendFax',{'FaxAccountId':_['isNil'](_0x5e3713[_0x9f75('0x59')]['id'])?undefined:_0x5e3713['params']['id'],'path':_[_0x9f75('0xa6')](_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')][0x0][_0x9f75('0x8')])?undefined:_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')][0x0][_0x9f75('0x8')],'fax':_[_0x9f75('0xa6')](_0x5e3713[_0x9f75('0x5e')]['to'][0x0])?undefined:_0x5e3713[_0x9f75('0x5e')]['to'][0x0],'AttachmentId':_0x5e3713[_0x9f75('0x5e')][_0x9f75('0xa2')][0x0]['id']},client9002)[_0x9f75('0x22')](function(_0x216673){logger[_0x9f75('0x23')](_0x9f75('0xb4'),_0x216673);})[_0x9f75('0x2b')](function(_0x2f7029){logger[_0x9f75('0x23')](_0x9f75('0xb4'),_0x2f7029);});return _0x69c9c9;})[_0x9f75('0x22')](respondWithResult(_0x19ccb3,null))['catch'](handleError(_0x19ccb3,null));};exports[_0x9f75('0xb5')]=function(_0x1fd6e8,_0x5a6438,_0x34cf35){return db[_0x9f75('0x53')]['find']({'where':{'id':_0x1fd6e8['params']['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x5a6438,null))[_0x9f75('0x22')](function(_0x4bcbd8){if(_0x4bcbd8){return _0x4bcbd8['addAgents'](_0x1fd6e8[_0x9f75('0x5e')][_0x9f75('0x6c')],_[_0x9f75('0xb6')](_0x1fd6e8[_0x9f75('0x5e')],[_0x9f75('0x6c'),'id'])||{})[_0x9f75('0xb1')](function(_0x1bd1ce){for(var _0x595fd4=0x0;_0x595fd4<_0x1fd6e8[_0x9f75('0x5e')][_0x9f75('0x6c')][_0x9f75('0x4a')];_0x595fd4+=0x1){socket[_0x9f75('0xb7')](_0x9f75('0xb8'),{'UserId':_0x1fd6e8[_0x9f75('0x5e')][_0x9f75('0x6c')][_0x595fd4],'FaxAccountId':_0x1fd6e8[_0x9f75('0x59')]['id']});}return _0x1bd1ce;});}})[_0x9f75('0x22')](respondWithResult(_0x5a6438,null))[_0x9f75('0x2b')](handleError(_0x5a6438,null));};exports['removeAgents']=function(_0xed88a1,_0x248e9e,_0x5a1f31){return db['FaxAccount']['find']({'where':{'id':_0xed88a1['params']['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x248e9e,null))['then'](function(_0x58cf1e){if(_0x58cf1e){return _0x58cf1e[_0x9f75('0xb9')](_0xed88a1['query'][_0x9f75('0x6c')])[_0x9f75('0x22')](function(){if(_['isArray'](_0xed88a1[_0x9f75('0x45')][_0x9f75('0x6c')])){for(var _0x38a506=0x0;_0x38a506<_0xed88a1['query'][_0x9f75('0x6c')]['length'];_0x38a506+=0x1){socket[_0x9f75('0xb7')]('userFaxAccount:remove',{'UserId':Number(_0xed88a1[_0x9f75('0x45')]['ids'][_0x38a506]),'FaxAccountId':Number(_0xed88a1[_0x9f75('0x59')]['id'])});}}else{socket[_0x9f75('0xb7')](_0x9f75('0xba'),{'UserId':Number(_0xed88a1[_0x9f75('0x45')][_0x9f75('0x6c')]),'FaxAccountId':Number(_0xed88a1[_0x9f75('0x59')]['id'])});}});}})[_0x9f75('0x22')](respondWithStatusCode(_0x248e9e,null))['catch'](handleError(_0x248e9e,null));};exports['getAgents']=function(_0x5940c5,_0x3f9cfc,_0x3da1b9){var _0x318ab2={};var _0x12a47d={};var _0x57f9e5;var _0x5e61e5;return db['FaxAccount'][_0x9f75('0x67')]({'where':{'id':_0x5940c5['params']['id']}})[_0x9f75('0x22')](handleEntityNotFound(_0x3f9cfc,null))[_0x9f75('0x22')](function(_0x11f099){if(_0x11f099){_0x57f9e5=_0x11f099;_0x12a47d['model']=_['keys'](db[_0x9f75('0x74')][_0x9f75('0x68')]);_0x12a47d[_0x9f75('0x45')]=_['keys'](_0x5940c5[_0x9f75('0x45')]);_0x12a47d[_0x9f75('0x46')]=_['intersection'](_0x12a47d[_0x9f75('0x44')],_0x12a47d[_0x9f75('0x45')]);_0x318ab2[_0x9f75('0x49')]=_['intersection'](_0x12a47d['model'],qs['fields'](_0x5940c5[_0x9f75('0x45')][_0x9f75('0x48')]));_0x318ab2[_0x9f75('0x49')]=_0x318ab2['attributes'][_0x9f75('0x4a')]?_0x318ab2[_0x9f75('0x49')]:_0x12a47d['model'];_0x318ab2['order']=qs[_0x9f75('0x4d')](_0x5940c5[_0x9f75('0x45')][_0x9f75('0x4d')]);_0x318ab2[_0x9f75('0x4e')]=qs[_0x9f75('0x46')](_[_0x9f75('0x4f')](_0x5940c5[_0x9f75('0x45')],_0x12a47d[_0x9f75('0x46')]));if(_0x5940c5['query']['filter']){_0x318ab2[_0x9f75('0x4e')]=_[_0x9f75('0x5b')](_0x318ab2[_0x9f75('0x4e')],{'$or':_[_0x9f75('0x41')](_0x318ab2['attributes'],function(_0x2eb8e7){var _0x26fc36={};_0x26fc36[_0x2eb8e7]={'$like':'%'+_0x5940c5['query'][_0x9f75('0x50')]+'%'};return _0x26fc36;})});}_0x318ab2=_[_0x9f75('0x5b')]({},_0x318ab2,_0x5940c5[_0x9f75('0x52')]);return _0x57f9e5['getAgents'](_0x318ab2);}})[_0x9f75('0x22')](function(_0x5e6e53){if(_0x5e6e53){_0x5e61e5=_0x5e6e53['length'];if(!_0x5940c5[_0x9f75('0x45')][_0x9f75('0x69')]('nolimit')){_0x318ab2[_0x9f75('0x30')]=qs[_0x9f75('0x30')](_0x5940c5['query']['limit']);_0x318ab2[_0x9f75('0x2f')]=qs[_0x9f75('0x2f')](_0x5940c5['query'][_0x9f75('0x2f')]);}return _0x57f9e5[_0x9f75('0xbb')](_0x318ab2);}})['then'](function(_0x270daa){if(_0x270daa){return _0x270daa?{'count':_0x5e61e5,'rows':_0x270daa}:null;}})['then'](respondWithResult(_0x3f9cfc,null))['catch'](handleError(_0x3f9cfc,null));};
\ No newline at end of file
+var _0x6739=['merge','includeAll','include','findAll','catch','show','Pause','keys','rawAttributes','options','find','create','user','get','role','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','params','describe','addDisposition','FaxAccountId','Disposition','getDispositions','findOne','intersection','pick','rows','addAnswer','CannedAnswer','getAnswers','nolimit','removeAnswers','ids','addInteraction','FaxInteraction','omit','getInteractions','CmContact','Contact','User','Owner','fullname','internal','color','tag','addApplications','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','FaxApplication','bulkCreate','findAndCountAll','priority','finally','getApplications','context','exten','localstationid','app','description','Fax\x20Extension','appdata','push','Answer','CDR(type)=inbound-fax','Set','ecm','gateway','faxdetect','maxrate','modem','t38timeout','FAXOPT(','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','ReceiveFax','addAccountApplications','transaction','VoiceExtension','updateAccountApplications','tech','createdAt','updatedAt','TrunkId','findById','FaxMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','Contacts','DESC','attachments','root','basename','CheckAfterSend','isNil','\x22%s\x22\x20<%s>','fax','defaults','ListId','List\x20not\x20found','Send\x20Fax\x20failed','Messages','Contact\x20not\x20found','spread','out','filename','ContactId','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','userFaxAccount:save','removeAgents','isArray','userFaxAccount:remove','getAgents','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxAccount.socket','register','jayson/promise','client','http','request','then','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','sendStatus','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','destroy','FaxAccounts','UserProfileResource','stack','send','mandatoryDispositionPause','FaxAccount','type','key','model','map','name','query','filters','attributes','fields','length','hasOwnProperty','order','sort','filter','where','VIRTUAL'];(function(_0x51baef,_0x15ab1a){var _0x593586=function(_0x3ea835){while(--_0x3ea835){_0x51baef['push'](_0x51baef['shift']());}};_0x593586(++_0x15ab1a);}(_0x6739,0x141));var _0x9673=function(_0x24dd66,_0x3af898){_0x24dd66=_0x24dd66-0x0;var _0x3b994a=_0x6739[_0x24dd66];return _0x3b994a;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x9673('0x0'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9673('0x1'));var moment=require('moment');var BPromise=require(_0x9673('0x2'));var Mustache=require(_0x9673('0x3'));var util=require(_0x9673('0x4'));var path=require(_0x9673('0x5'));var sox=require(_0x9673('0x6'));var csv=require(_0x9673('0x7'));var ejs=require(_0x9673('0x8'));var fs=require('fs');var fs_extra=require(_0x9673('0x9'));var _=require(_0x9673('0xa'));var squel=require(_0x9673('0xb'));var crypto=require(_0x9673('0xc'));var jsforce=require(_0x9673('0xd'));var deskjs=require(_0x9673('0xe'));var toCsv=require(_0x9673('0x7'));var querystring=require(_0x9673('0xf'));var Papa=require(_0x9673('0x10'));var Redis=require(_0x9673('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x9673('0x12'));var hardwareService=require(_0x9673('0x13'));var logger=require(_0x9673('0x14'))(_0x9673('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x9673('0x16'));var db=require(_0x9673('0x17'))['db'];config[_0x9673('0x18')]=_['defaults'](config[_0x9673('0x18')],{'host':_0x9673('0x19'),'port':0x18eb});var socket=require(_0x9673('0x1a'))(new Redis(config[_0x9673('0x18')]));require(_0x9673('0x1b'))[_0x9673('0x1c')](socket);var jayson=require(_0x9673('0x1d'));var client=jayson[_0x9673('0x1e')][_0x9673('0x1f')]({'port':0x232c});var client9002=jayson[_0x9673('0x1e')]['http']({'port':0x232a});function respondWithRpcPromise(_0x43fd64,_0x1aed05,_0x4e900a,_0x496f47){return new BPromise(function(_0x2368b9,_0x5da677){var _0x51185e=_0x496f47||client;return _0x51185e[_0x9673('0x20')](_0x43fd64,_0x4e900a)[_0x9673('0x21')](function(_0x18a5d5){logger['info'](_0x9673('0x22'),_0x1aed05,_0x9673('0x23'));logger[_0x9673('0x24')](_0x9673('0x25'),_0x1aed05,_0x9673('0x23'),JSON[_0x9673('0x26')](_0x18a5d5));if(_0x18a5d5['error']){if(_0x18a5d5[_0x9673('0x27')][_0x9673('0x28')]===0x1f4){logger['error']('FaxAccount,\x20%s,\x20%s',_0x1aed05,_0x18a5d5[_0x9673('0x27')][_0x9673('0x29')]);return _0x5da677(_0x18a5d5['error'][_0x9673('0x29')]);}logger[_0x9673('0x27')]('FaxAccount,\x20%s,\x20%s',_0x1aed05,_0x18a5d5[_0x9673('0x27')][_0x9673('0x29')]);return _0x2368b9(_0x18a5d5[_0x9673('0x27')][_0x9673('0x29')]);}else{logger[_0x9673('0x2a')](_0x9673('0x22'),_0x1aed05,'request\x20sent');_0x2368b9(_0x18a5d5[_0x9673('0x2b')][_0x9673('0x29')]);}})['catch'](function(_0x39d876){logger['error'](_0x9673('0x22'),_0x1aed05,_0x39d876);_0x5da677(_0x39d876);});});}function respondWithStatusCode(_0x382e47,_0x5ec1f9){_0x5ec1f9=_0x5ec1f9||0xcc;return function(_0x5ed424){if(_0x5ed424){return _0x382e47[_0x9673('0x2c')](_0x5ec1f9);}return _0x382e47['status'](_0x5ec1f9)['end']();};}function respondWithResult(_0x5b3c65,_0x35ef4e){_0x35ef4e=_0x35ef4e||0xc8;return function(_0xbf5400){if(_0xbf5400){return _0x5b3c65[_0x9673('0x2d')](_0x35ef4e)[_0x9673('0x2e')](_0xbf5400);}};}function respondWithFilteredResult(_0xf8964,_0xf75b50){return function(_0x3d0e86){if(_0x3d0e86){var _0x17fa2b=typeof _0xf75b50[_0x9673('0x2f')]===_0x9673('0x30')&&typeof _0xf75b50['limit']==='undefined';var _0x186bcc=_0x3d0e86['count'];var _0x5af24d=_0x17fa2b?0x0:_0xf75b50[_0x9673('0x2f')];var _0x35a990=_0x17fa2b?_0x3d0e86[_0x9673('0x31')]:_0xf75b50[_0x9673('0x2f')]+_0xf75b50[_0x9673('0x32')];var _0x40cce7;if(_0x35a990>=_0x186bcc){_0x35a990=_0x186bcc;_0x40cce7=0xc8;}else{_0x40cce7=0xce;}_0xf8964[_0x9673('0x2d')](_0x40cce7);return _0xf8964[_0x9673('0x33')](_0x9673('0x34'),_0x5af24d+'-'+_0x35a990+'/'+_0x186bcc)['json'](_0x3d0e86);}return null;};}function patchUpdates(_0x5c6fe0){return function(_0xf864fb){try{jsonpatch[_0x9673('0x35')](_0xf864fb,_0x5c6fe0,!![]);}catch(_0x2be483){return BPromise[_0x9673('0x36')](_0x2be483);}return _0xf864fb[_0x9673('0x37')]();};}function saveUpdates(_0x2697bb,_0x164a71){return function(_0x18edae){if(_0x18edae){return _0x18edae['update'](_0x2697bb)[_0x9673('0x21')](function(_0x59dd3f){return _0x59dd3f;});}return null;};}function removeEntity(_0x3d42b2,_0x2ec826){return function(_0x2d59cc){if(_0x2d59cc){return _0x2d59cc[_0x9673('0x38')]()[_0x9673('0x21')](function(){var _0x196877=_0x2d59cc['get']({'plain':!![]});var _0x5e2ab7=_0x9673('0x39');return db[_0x9673('0x3a')]['destroy']({'where':{'type':_0x5e2ab7,'resourceId':_0x196877['id']}})[_0x9673('0x21')](function(){return _0x2d59cc;});})[_0x9673('0x21')](function(){_0x3d42b2['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3eb5e7,_0x55fcfc){return function(_0x1ee02f){if(!_0x1ee02f){_0x3eb5e7[_0x9673('0x2c')](0x194);}return _0x1ee02f;};}function handleError(_0x593b08,_0x7cc8f9){_0x7cc8f9=_0x7cc8f9||0x1f4;return function(_0x55a7db){logger['error'](_0x55a7db[_0x9673('0x3b')]);if(_0x55a7db['name']){delete _0x55a7db['name'];}_0x593b08['status'](_0x7cc8f9)[_0x9673('0x3c')](_0x55a7db);};}exports['index']=function(_0x38ec96,_0x5e8792){var _0x35ba98={'include':[{'model':db['Pause'],'as':_0x9673('0x3d')}]},_0x52fb30={},_0xb71e1b={'count':0x0,'rows':[]};var _0x1b4412=_['map'](db[_0x9673('0x3e')]['rawAttributes'],function(_0x3402f5){return{'name':_0x3402f5['fieldName'],'type':_0x3402f5[_0x9673('0x3f')][_0x9673('0x40')]};});_0x52fb30[_0x9673('0x41')]=_[_0x9673('0x42')](_0x1b4412,_0x9673('0x43'));_0x52fb30[_0x9673('0x44')]=_['keys'](_0x38ec96['query']);_0x52fb30[_0x9673('0x45')]=_['intersection'](_0x52fb30['model'],_0x52fb30[_0x9673('0x44')]);_0x35ba98[_0x9673('0x46')]=_['intersection'](_0x52fb30[_0x9673('0x41')],qs[_0x9673('0x47')](_0x38ec96[_0x9673('0x44')]['fields']));_0x35ba98[_0x9673('0x46')]=_0x35ba98[_0x9673('0x46')][_0x9673('0x48')]?_0x35ba98['attributes']:_0x52fb30['model'];if(!_0x38ec96['query'][_0x9673('0x49')]('nolimit')){_0x35ba98['limit']=qs[_0x9673('0x32')](_0x38ec96[_0x9673('0x44')]['limit']);_0x35ba98[_0x9673('0x2f')]=qs['offset'](_0x38ec96[_0x9673('0x44')]['offset']);}_0x35ba98[_0x9673('0x4a')]=qs[_0x9673('0x4b')](_0x38ec96[_0x9673('0x44')][_0x9673('0x4b')]);_0x35ba98['where']=qs['filters'](_['pick'](_0x38ec96[_0x9673('0x44')],_0x52fb30[_0x9673('0x45')]),_0x1b4412);if(_0x38ec96[_0x9673('0x44')][_0x9673('0x4c')]){_0x35ba98[_0x9673('0x4d')]=_['merge'](_0x35ba98[_0x9673('0x4d')],{'$or':_[_0x9673('0x42')](_0x1b4412,function(_0x37eab3){if(_0x37eab3[_0x9673('0x3f')]!==_0x9673('0x4e')){var _0x416ce9={};_0x416ce9[_0x37eab3[_0x9673('0x43')]]={'$like':'%'+_0x38ec96['query'][_0x9673('0x4c')]+'%'};return _0x416ce9;}})});}_0x35ba98=_[_0x9673('0x4f')]({},_0x35ba98,_0x38ec96['options']);var _0x52a0b9={'where':_0x35ba98[_0x9673('0x4d')]};return db[_0x9673('0x3e')][_0x9673('0x31')](_0x52a0b9)[_0x9673('0x21')](function(_0x31555d){_0xb71e1b[_0x9673('0x31')]=_0x31555d;if(_0x38ec96[_0x9673('0x44')][_0x9673('0x50')]){_0x35ba98[_0x9673('0x51')]=[{'all':!![]}];}return db[_0x9673('0x3e')][_0x9673('0x52')](_0x35ba98);})[_0x9673('0x21')](function(_0x48ea86){_0xb71e1b['rows']=_0x48ea86;return _0xb71e1b;})[_0x9673('0x21')](respondWithFilteredResult(_0x5e8792,_0x35ba98))[_0x9673('0x53')](handleError(_0x5e8792,null));};exports[_0x9673('0x54')]=function(_0x51c586,_0x8c693){var _0x3a02c0={'raw':![],'where':{'id':_0x51c586['params']['id']},'include':[{'model':db[_0x9673('0x55')],'as':_0x9673('0x3d')}]},_0x48bc86={};_0x48bc86[_0x9673('0x41')]=_[_0x9673('0x56')](db['FaxAccount'][_0x9673('0x57')]);_0x48bc86[_0x9673('0x44')]=_[_0x9673('0x56')](_0x51c586[_0x9673('0x44')]);_0x48bc86[_0x9673('0x45')]=_['intersection'](_0x48bc86[_0x9673('0x41')],_0x48bc86[_0x9673('0x44')]);_0x3a02c0['attributes']=_['intersection'](_0x48bc86[_0x9673('0x41')],qs[_0x9673('0x47')](_0x51c586[_0x9673('0x44')][_0x9673('0x47')]));_0x3a02c0[_0x9673('0x46')]=_0x3a02c0[_0x9673('0x46')][_0x9673('0x48')]?_0x3a02c0[_0x9673('0x46')]:_0x48bc86[_0x9673('0x41')];if(_0x51c586[_0x9673('0x44')]['includeAll']){_0x3a02c0['include']=[{'all':!![]}];}_0x3a02c0=_[_0x9673('0x4f')]({},_0x3a02c0,_0x51c586[_0x9673('0x58')]);return db[_0x9673('0x3e')][_0x9673('0x59')](_0x3a02c0)['then'](handleEntityNotFound(_0x8c693,null))[_0x9673('0x21')](respondWithResult(_0x8c693,null))[_0x9673('0x53')](handleError(_0x8c693,null));};exports[_0x9673('0x5a')]=function(_0x15380e,_0x7defcc){return db['FaxAccount']['create'](_0x15380e['body'],{})[_0x9673('0x21')](function(_0x385bca){var _0x2a4d2b=_0x15380e[_0x9673('0x5b')][_0x9673('0x5c')]({'plain':!![]});if(!_0x2a4d2b)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2a4d2b[_0x9673('0x5d')]==='user'){var _0x30e237=_0x385bca[_0x9673('0x5c')]({'plain':!![]});var _0x2c7a1c=_0x9673('0x39');return db['UserProfileSection']['find']({'where':{'name':_0x2c7a1c,'userProfileId':_0x2a4d2b['userProfileId']},'raw':!![]})[_0x9673('0x21')](function(_0x2046d5){if(_0x2046d5&&_0x2046d5['autoAssociation']===0x0){return db[_0x9673('0x3a')][_0x9673('0x5a')]({'name':_0x30e237['name'],'resourceId':_0x30e237['id'],'type':_0x2046d5[_0x9673('0x43')],'sectionId':_0x2046d5['id']},{})[_0x9673('0x21')](function(){return _0x385bca;});}else{return _0x385bca;}})[_0x9673('0x53')](function(_0x5e2892){logger[_0x9673('0x27')](_0x9673('0x5e'),_0x5e2892);throw _0x5e2892;});}return _0x385bca;})[_0x9673('0x21')](respondWithResult(_0x7defcc,0xc9))[_0x9673('0x53')](handleError(_0x7defcc,null));};exports[_0x9673('0x5f')]=function(_0x5b4da8,_0x5d0229){if(_0x5b4da8[_0x9673('0x60')]['id']){delete _0x5b4da8[_0x9673('0x60')]['id'];}return db['FaxAccount'][_0x9673('0x59')]({'where':{'id':_0x5b4da8['params']['id']},'include':[{'model':db[_0x9673('0x55')],'as':_0x9673('0x3d')}]})['then'](handleEntityNotFound(_0x5d0229,null))[_0x9673('0x21')](saveUpdates(_0x5b4da8[_0x9673('0x60')],null))[_0x9673('0x21')](respondWithResult(_0x5d0229,null))['catch'](handleError(_0x5d0229,null));};exports['destroy']=function(_0x54a16b,_0x3e4fa1){return db['FaxAccount']['find']({'where':{'id':_0x54a16b[_0x9673('0x61')]['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x3e4fa1,null))[_0x9673('0x21')](removeEntity(_0x3e4fa1,null))['catch'](handleError(_0x3e4fa1,null));};exports[_0x9673('0x62')]=function(_0x38d2d2,_0x43ba1a){return db[_0x9673('0x3e')][_0x9673('0x62')]()['then'](respondWithResult(_0x43ba1a,null))[_0x9673('0x53')](handleError(_0x43ba1a,null));};exports[_0x9673('0x63')]=function(_0x322127,_0x41c6f8,_0x534f14){if(_0x322127[_0x9673('0x60')]['id']){delete _0x322127[_0x9673('0x60')]['id'];}return db[_0x9673('0x3e')][_0x9673('0x59')]({'where':{'id':_0x322127['params']['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x41c6f8,null))[_0x9673('0x21')](function(_0x5e0d1a){if(_0x5e0d1a){_0x322127[_0x9673('0x60')][_0x9673('0x64')]=_0x5e0d1a['id'];return db[_0x9673('0x65')][_0x9673('0x5a')](_0x322127[_0x9673('0x60')]);}})[_0x9673('0x21')](respondWithResult(_0x41c6f8,null))['catch'](handleError(_0x41c6f8,null));};exports[_0x9673('0x66')]=function(_0x1d872e,_0x8f42a0,_0x2e3ee0){var _0x54751c={'raw':![],'where':{}};var _0xedc3dd={};var _0x418ec7={'count':0x0,'rows':[]};return db[_0x9673('0x3e')][_0x9673('0x67')]({'where':{'id':_0x1d872e[_0x9673('0x61')]['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x8f42a0,null))[_0x9673('0x21')](function(_0x526f33){if(_0x526f33){_0xedc3dd[_0x9673('0x41')]=_[_0x9673('0x56')](db[_0x9673('0x65')][_0x9673('0x57')]);_0xedc3dd[_0x9673('0x44')]=_['keys'](_0x1d872e[_0x9673('0x44')]);_0xedc3dd[_0x9673('0x45')]=_[_0x9673('0x68')](_0xedc3dd['model'],_0xedc3dd[_0x9673('0x44')]);_0x54751c[_0x9673('0x46')]=_['intersection'](_0xedc3dd[_0x9673('0x41')],qs[_0x9673('0x47')](_0x1d872e[_0x9673('0x44')][_0x9673('0x47')]));_0x54751c[_0x9673('0x46')]=_0x54751c[_0x9673('0x46')]['length']?_0x54751c[_0x9673('0x46')]:_0xedc3dd[_0x9673('0x41')];if(!_0x1d872e[_0x9673('0x44')][_0x9673('0x49')]('nolimit')){_0x54751c[_0x9673('0x32')]=qs[_0x9673('0x32')](_0x1d872e['query']['limit']);_0x54751c[_0x9673('0x2f')]=qs[_0x9673('0x2f')](_0x1d872e[_0x9673('0x44')]['offset']);}_0x54751c[_0x9673('0x4a')]=qs[_0x9673('0x4b')](_0x1d872e[_0x9673('0x44')][_0x9673('0x4b')]);_0x54751c[_0x9673('0x4d')]=qs[_0x9673('0x45')](_[_0x9673('0x69')](_0x1d872e[_0x9673('0x44')],_0xedc3dd[_0x9673('0x45')]));_0x54751c[_0x9673('0x4d')][_0x9673('0x64')]=_0x526f33['id'];if(_0x1d872e[_0x9673('0x44')][_0x9673('0x4c')]){_0x54751c[_0x9673('0x4d')]=_[_0x9673('0x4f')](_0x54751c[_0x9673('0x4d')],{'$or':_[_0x9673('0x42')](_0x54751c[_0x9673('0x46')],function(_0x5a5b0c){var _0x3ee61f={};_0x3ee61f[_0x5a5b0c]={'$like':'%'+_0x1d872e['query'][_0x9673('0x4c')]+'%'};return _0x3ee61f;})});}_0x54751c=_['merge']({},_0x54751c,_0x1d872e[_0x9673('0x58')]);return db[_0x9673('0x65')][_0x9673('0x31')]({'where':_0x54751c[_0x9673('0x4d')]})[_0x9673('0x21')](function(_0x4e3b99){_0x418ec7[_0x9673('0x31')]=_0x4e3b99;if(_0x1d872e[_0x9673('0x44')][_0x9673('0x50')]){_0x54751c[_0x9673('0x51')]=[{'all':!![]}];}return db['Disposition'][_0x9673('0x52')](_0x54751c);})[_0x9673('0x21')](function(_0x5c9c86){_0x418ec7[_0x9673('0x6a')]=_0x5c9c86;return _0x418ec7;});}})[_0x9673('0x21')](respondWithFilteredResult(_0x8f42a0,_0x54751c))[_0x9673('0x53')](handleError(_0x8f42a0,null));};exports['removeDispositions']=function(_0x563944,_0x468411,_0x214ad4){return db[_0x9673('0x3e')][_0x9673('0x59')]({'where':{'id':_0x563944['params']['id']}})['then'](handleEntityNotFound(_0x468411,null))[_0x9673('0x21')](function(_0x5493e0){if(_0x5493e0){return _0x5493e0['removeDispositions'](_0x563944['query']['ids']);}})[_0x9673('0x21')](respondWithStatusCode(_0x468411,null))[_0x9673('0x53')](handleError(_0x468411,null));};exports[_0x9673('0x6b')]=function(_0x541e27,_0x29a025,_0x16fb54){if(_0x541e27[_0x9673('0x60')]['id']){delete _0x541e27[_0x9673('0x60')]['id'];}return db['FaxAccount'][_0x9673('0x59')]({'where':{'id':_0x541e27[_0x9673('0x61')]['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x29a025,null))[_0x9673('0x21')](function(_0x1e75d2){if(_0x1e75d2){_0x541e27['body']['FaxAccountId']=_0x1e75d2['id'];return db[_0x9673('0x6c')][_0x9673('0x5a')](_0x541e27['body']);}})[_0x9673('0x21')](respondWithResult(_0x29a025,null))[_0x9673('0x53')](handleError(_0x29a025,null));};exports[_0x9673('0x6d')]=function(_0x2d7488,_0xa93a97,_0x36d2c7){var _0x39e20e={'raw':![],'where':{}};var _0x2f5ad1={};var _0x3679e8={'count':0x0,'rows':[]};return db[_0x9673('0x3e')][_0x9673('0x67')]({'where':{'id':_0x2d7488[_0x9673('0x61')]['id']}})[_0x9673('0x21')](handleEntityNotFound(_0xa93a97,null))['then'](function(_0x1c2f84){if(_0x1c2f84){_0x2f5ad1[_0x9673('0x41')]=_['keys'](db['CannedAnswer'][_0x9673('0x57')]);_0x2f5ad1['query']=_['keys'](_0x2d7488[_0x9673('0x44')]);_0x2f5ad1[_0x9673('0x45')]=_[_0x9673('0x68')](_0x2f5ad1[_0x9673('0x41')],_0x2f5ad1['query']);_0x39e20e[_0x9673('0x46')]=_['intersection'](_0x2f5ad1['model'],qs[_0x9673('0x47')](_0x2d7488['query'][_0x9673('0x47')]));_0x39e20e[_0x9673('0x46')]=_0x39e20e[_0x9673('0x46')]['length']?_0x39e20e['attributes']:_0x2f5ad1['model'];if(!_0x2d7488[_0x9673('0x44')][_0x9673('0x49')](_0x9673('0x6e'))){_0x39e20e[_0x9673('0x32')]=qs[_0x9673('0x32')](_0x2d7488[_0x9673('0x44')][_0x9673('0x32')]);_0x39e20e[_0x9673('0x2f')]=qs[_0x9673('0x2f')](_0x2d7488[_0x9673('0x44')][_0x9673('0x2f')]);}_0x39e20e[_0x9673('0x4a')]=qs[_0x9673('0x4b')](_0x2d7488[_0x9673('0x44')][_0x9673('0x4b')]);_0x39e20e[_0x9673('0x4d')]=qs[_0x9673('0x45')](_[_0x9673('0x69')](_0x2d7488['query'],_0x2f5ad1['filters']));_0x39e20e[_0x9673('0x4d')][_0x9673('0x64')]=_0x1c2f84['id'];if(_0x2d7488[_0x9673('0x44')]['filter']){_0x39e20e['where']=_[_0x9673('0x4f')](_0x39e20e[_0x9673('0x4d')],{'$or':_[_0x9673('0x42')](_0x39e20e['attributes'],function(_0x3a3fbd){var _0x35a21d={};_0x35a21d[_0x3a3fbd]={'$like':'%'+_0x2d7488[_0x9673('0x44')]['filter']+'%'};return _0x35a21d;})});}_0x39e20e=_[_0x9673('0x4f')]({},_0x39e20e,_0x2d7488[_0x9673('0x58')]);return db[_0x9673('0x6c')]['count']({'where':_0x39e20e[_0x9673('0x4d')]})['then'](function(_0x2f7904){_0x3679e8[_0x9673('0x31')]=_0x2f7904;if(_0x2d7488[_0x9673('0x44')][_0x9673('0x50')]){_0x39e20e[_0x9673('0x51')]=[{'all':!![]}];}return db[_0x9673('0x6c')][_0x9673('0x52')](_0x39e20e);})[_0x9673('0x21')](function(_0xfef522){_0x3679e8[_0x9673('0x6a')]=_0xfef522;return _0x3679e8;});}})[_0x9673('0x21')](respondWithFilteredResult(_0xa93a97,_0x39e20e))[_0x9673('0x53')](handleError(_0xa93a97,null));};exports[_0x9673('0x6f')]=function(_0x1d9aa4,_0x2f9b67,_0x37b233){return db[_0x9673('0x3e')][_0x9673('0x59')]({'where':{'id':_0x1d9aa4['params']['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x2f9b67,null))['then'](function(_0x2186cc){if(_0x2186cc){return _0x2186cc['removeAnswers'](_0x1d9aa4['query'][_0x9673('0x70')]);}})[_0x9673('0x21')](respondWithStatusCode(_0x2f9b67,null))[_0x9673('0x53')](handleError(_0x2f9b67,null));};exports[_0x9673('0x71')]=function(_0xd73cd1,_0x380a33,_0x3e3890){return db[_0x9673('0x72')]['find']({'where':{'id':_0xd73cd1[_0x9673('0x61')]['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x380a33,null))[_0x9673('0x21')](function(_0x28a4d2){if(_0x28a4d2){return _0x28a4d2[_0x9673('0x71')](_0xd73cd1['body'][_0x9673('0x70')],_[_0x9673('0x73')](_0xd73cd1[_0x9673('0x60')],[_0x9673('0x70'),'id'])||{});}})[_0x9673('0x21')](respondWithResult(_0x380a33,null))['catch'](handleError(_0x380a33,null));};exports[_0x9673('0x74')]=function(_0x253c40,_0x379b59,_0x40fc90){var _0x17b47f={'raw':![],'where':{}};var _0x4ed828={};var _0x2ec904={'count':0x0,'rows':[]};return db[_0x9673('0x3e')]['findOne']({'where':{'id':_0x253c40['params']['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x379b59,null))[_0x9673('0x21')](function(_0x50fc1b){if(_0x50fc1b){_0x4ed828[_0x9673('0x41')]=_[_0x9673('0x56')](db[_0x9673('0x72')]['rawAttributes']);_0x4ed828[_0x9673('0x44')]=_['keys'](_0x253c40[_0x9673('0x44')]);_0x4ed828[_0x9673('0x45')]=_[_0x9673('0x68')](_0x4ed828[_0x9673('0x41')],_0x4ed828[_0x9673('0x44')]);_0x17b47f[_0x9673('0x46')]=_[_0x9673('0x68')](_0x4ed828['model'],qs[_0x9673('0x47')](_0x253c40[_0x9673('0x44')][_0x9673('0x47')]));_0x17b47f['attributes']=_0x17b47f['attributes'][_0x9673('0x48')]?_0x17b47f['attributes']:_0x4ed828[_0x9673('0x41')];if(!_0x253c40[_0x9673('0x44')][_0x9673('0x49')](_0x9673('0x6e'))){_0x17b47f[_0x9673('0x32')]=qs[_0x9673('0x32')](_0x253c40[_0x9673('0x44')][_0x9673('0x32')]);_0x17b47f[_0x9673('0x2f')]=qs[_0x9673('0x2f')](_0x253c40[_0x9673('0x44')]['offset']);}_0x17b47f['order']=qs['sort'](_0x253c40[_0x9673('0x44')]['sort']);_0x17b47f['where']=qs[_0x9673('0x45')](_[_0x9673('0x69')](_0x253c40[_0x9673('0x44')],_0x4ed828[_0x9673('0x45')]));_0x17b47f['where'][_0x9673('0x64')]=_0x50fc1b['id'];if(_0x253c40['query'][_0x9673('0x4c')]){_0x17b47f[_0x9673('0x4d')]=_[_0x9673('0x4f')](_0x17b47f[_0x9673('0x4d')],{'$or':_[_0x9673('0x42')](_0x17b47f[_0x9673('0x46')],function(_0x13d255){var _0x32561f={};_0x32561f[_0x13d255]={'$like':'%'+_0x253c40['query'][_0x9673('0x4c')]+'%'};return _0x32561f;})});}_0x17b47f=_[_0x9673('0x4f')]({},_0x17b47f,_0x253c40[_0x9673('0x58')]);return db[_0x9673('0x72')]['count']({'where':_0x17b47f[_0x9673('0x4d')]})[_0x9673('0x21')](function(_0x3dfff4){_0x2ec904[_0x9673('0x31')]=_0x3dfff4;if(_0x253c40[_0x9673('0x44')]['includeAll']){_0x17b47f[_0x9673('0x51')]=[{'model':db[_0x9673('0x75')],'as':_0x9673('0x76'),'required':![]},{'model':db[_0x9673('0x77')],'as':_0x9673('0x78'),'attributes':[_0x9673('0x43'),_0x9673('0x79'),_0x9673('0x7a')],'required':![]},{'model':db['Tag'],'as':'Tags','attributes':['id',_0x9673('0x43'),_0x9673('0x7b')],'where':_0x253c40[_0x9673('0x44')][_0x9673('0x7c')]?{'id':_0x253c40[_0x9673('0x44')][_0x9673('0x7c')]}:undefined,'required':_0x253c40['query'][_0x9673('0x7c')]?!![]:![]}];}return db[_0x9673('0x72')][_0x9673('0x52')](_0x17b47f);})[_0x9673('0x21')](function(_0xfc4dd4){_0x2ec904[_0x9673('0x6a')]=_0xfc4dd4;return _0x2ec904;});}})[_0x9673('0x21')](respondWithFilteredResult(_0x379b59,_0x17b47f))['catch'](handleError(_0x379b59,null));};exports[_0x9673('0x7d')]=function(_0x202df0,_0x370f86){var _0x385b43=_0x202df0['params']['id'];var _0x5b3c0e=_0x202df0[_0x9673('0x60')];var _0x41fb46=0xc8;var _0x1addaf=null;return db[_0x9673('0x7e')]['transaction']({'isolationLevel':db[_0x9673('0x7e')][_0x9673('0x7f')][_0x9673('0x80')][_0x9673('0x81')]},function(_0x1edb7f){return db[_0x9673('0x3e')][_0x9673('0x67')]({'where':{'id':_0x385b43},'transaction':_0x1edb7f})[_0x9673('0x21')](function(_0x2f95da){if(_0x2f95da){return db[_0x9673('0x82')]['destroy']({'where':{'FaxAccountId':_0x385b43},'transaction':_0x1edb7f})[_0x9673('0x21')](function(){var _0x179e04=_[_0x9673('0x42')](_0x5b3c0e,function(_0x6e3f06){_0x6e3f06['FaxAccountId']=_0x385b43;return _0x6e3f06;});return db[_0x9673('0x82')][_0x9673('0x83')](_0x179e04,{'transaction':_0x1edb7f});});}else{_0x41fb46=0x194;_0x1addaf=[];}});})['then'](function(){if(_0x41fb46!==0x194){return db[_0x9673('0x82')][_0x9673('0x84')]({'where':{'FaxAccountId':_0x385b43},'order':_0x9673('0x85')})[_0x9673('0x21')](function(_0x20da35){_0x1addaf=_0x20da35;});}})[_0x9673('0x53')](function(_0x1f4086){_0x41fb46=0x1f4;logger[_0x9673('0x27')](_0x1f4086[_0x9673('0x3b')]);if(_0x1f4086[_0x9673('0x43')]){delete _0x1f4086[_0x9673('0x43')];}_0x1addaf=_0x1f4086;})[_0x9673('0x86')](function(){if(_0x1addaf===null){_0x370f86['sendStatus'](_0x41fb46);}else{if(_0x41fb46===0x1f4){_0x370f86[_0x9673('0x2d')](_0x41fb46)[_0x9673('0x3c')](_0x1addaf);}else{_0x370f86[_0x9673('0x2d')](_0x41fb46)[_0x9673('0x2e')](_0x1addaf);}}});};exports[_0x9673('0x87')]=function(_0x799005,_0x5519b0,_0x42addf){var _0x56e244={};var _0x2fa300={};var _0x1da689;var _0x4a1c96;return db['FaxAccount'][_0x9673('0x67')]({'where':{'id':_0x799005[_0x9673('0x61')]['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x5519b0,null))[_0x9673('0x21')](function(_0x5d63b9){if(_0x5d63b9){_0x1da689=_0x5d63b9;_0x2fa300[_0x9673('0x41')]=_[_0x9673('0x56')](db[_0x9673('0x82')][_0x9673('0x57')]);_0x2fa300[_0x9673('0x44')]=_['keys'](_0x799005[_0x9673('0x44')]);_0x2fa300[_0x9673('0x45')]=_[_0x9673('0x68')](_0x2fa300[_0x9673('0x41')],_0x2fa300[_0x9673('0x44')]);_0x56e244[_0x9673('0x46')]=_['intersection'](_0x2fa300[_0x9673('0x41')],qs[_0x9673('0x47')](_0x799005['query'][_0x9673('0x47')]));_0x56e244[_0x9673('0x46')]=_0x56e244[_0x9673('0x46')][_0x9673('0x48')]?_0x56e244[_0x9673('0x46')]:_0x2fa300[_0x9673('0x41')];_0x56e244[_0x9673('0x4a')]=qs[_0x9673('0x4b')](_0x799005[_0x9673('0x44')][_0x9673('0x4b')]);_0x56e244[_0x9673('0x4d')]=qs['filters'](_['pick'](_0x799005[_0x9673('0x44')],_0x2fa300[_0x9673('0x45')]));if(_0x799005[_0x9673('0x44')][_0x9673('0x4c')]){_0x56e244[_0x9673('0x4d')]=_[_0x9673('0x4f')](_0x56e244['where'],{'$or':_[_0x9673('0x42')](_0x56e244[_0x9673('0x46')],function(_0x57abc1){var _0x419301={};_0x419301[_0x57abc1]={'$like':'%'+_0x799005[_0x9673('0x44')][_0x9673('0x4c')]+'%'};return _0x419301;})});}_0x56e244=_[_0x9673('0x4f')]({},_0x56e244,_0x799005[_0x9673('0x58')]);return _0x1da689[_0x9673('0x87')](_0x56e244);}})[_0x9673('0x21')](function(_0xd2f52d){if(_0xd2f52d){_0x4a1c96=_0xd2f52d['length'];if(!_0x799005[_0x9673('0x44')]['hasOwnProperty'](_0x9673('0x6e'))){_0x56e244[_0x9673('0x32')]=qs['limit'](_0x799005['query'][_0x9673('0x32')]);_0x56e244['offset']=qs[_0x9673('0x2f')](_0x799005[_0x9673('0x44')][_0x9673('0x2f')]);}return _0x1da689[_0x9673('0x87')](_0x56e244);}})[_0x9673('0x21')](function(_0x3f17a7){if(_0x3f17a7){return _0x3f17a7?{'count':_0x4a1c96,'rows':_0x3f17a7}:null;}})[_0x9673('0x21')](respondWithResult(_0x5519b0,null))['catch'](handleError(_0x5519b0,null));};function Extension(_0x229c4f,_0x169ad3,_0x3dc618,_0x5d05ff){this[_0x9673('0x88')]='from-voip-provider';this[_0x9673('0x89')]=_0x229c4f[_0x9673('0x8a')];this[_0x9673('0x8b')]=_0x5d05ff;this[_0x9673('0x3f')]='system';this[_0x9673('0x8c')]=_0x9673('0x8d');this[_0x9673('0x64')]=_0x229c4f['id'];this['priority']=_0x169ad3;this[_0x9673('0x8e')]=_0x3dc618;}function createExtensionsReciveFax(_0x2442ca){var _0x370cf5=0x1;var _0x5eed9b=[];_0x5eed9b[_0x9673('0x8f')](new Extension(_0x2442ca,_0x370cf5,'',_0x9673('0x90')));_0x370cf5+=0x1;_0x5eed9b[_0x9673('0x8f')](new Extension(_0x2442ca,_0x370cf5,_0x9673('0x91'),_0x9673('0x92')));_0x370cf5+=0x1;for(var _0x2f1ad6 in _0x2442ca){if(_0x2442ca[_0x9673('0x49')](_0x2f1ad6)&&(_0x2f1ad6===_0x9673('0x93')||_0x2f1ad6===_0x9673('0x8a')||_0x2f1ad6===_0x9673('0x94')||_0x2f1ad6===_0x9673('0x95')||_0x2f1ad6==='headerinfo'||_0x2f1ad6===_0x9673('0x96')||_0x2f1ad6==='minrate'||_0x2f1ad6===_0x9673('0x97')||_0x2f1ad6===_0x9673('0x98'))){_0x5eed9b[_0x9673('0x8f')](new Extension(_0x2442ca,_0x370cf5,_0x9673('0x99')+_0x2f1ad6+')='+_0x2442ca[_0x2f1ad6],_0x9673('0x92')));_0x370cf5+=0x1;}}_0x5eed9b[_0x9673('0x8f')](new Extension(_0x2442ca,_0x370cf5,'6','Wait'));_0x370cf5+=0x1;_0x5eed9b[_0x9673('0x8f')](new Extension(_0x2442ca,_0x370cf5,_0x9673('0x9a'),_0x9673('0x9b')));_0x370cf5=0x0;return _0x5eed9b;}exports[_0x9673('0x9c')]=function(_0x1747e6,_0x34241d,_0x245eda){var _0x5c68d7;return db[_0x9673('0x7e')][_0x9673('0x9d')](function(_0xd7e5a3){return db[_0x9673('0x3e')][_0x9673('0x5a')](_0x1747e6[_0x9673('0x60')],{'transaction':_0xd7e5a3})[_0x9673('0x21')](function(_0x27a1c8){_0x5c68d7=_0x27a1c8['get']({'plain':!![]});return db[_0x9673('0x9e')][_0x9673('0x83')](createExtensionsReciveFax(_0x5c68d7),{'transaction':_0xd7e5a3});});})[_0x9673('0x21')](function(){return _0x5c68d7;})[_0x9673('0x21')](respondWithResult(_0x34241d,null))[_0x9673('0x53')](handleError(_0x34241d,null));};exports[_0x9673('0x9f')]=function(_0x39e9e0,_0x1a88a2,_0x30c6e5){var _0x2eb75f;return db[_0x9673('0x7e')][_0x9673('0x9d')](function(_0x28ac47){return db[_0x9673('0x3e')]['update'](_0x39e9e0[_0x9673('0x60')],{'where':{'id':_0x39e9e0[_0x9673('0x60')]['id']},'transaction':_0x28ac47})[_0x9673('0x21')](function(_0x2855a2){return db[_0x9673('0x9e')][_0x9673('0x38')]({'where':{'FaxAccountId':_0x39e9e0[_0x9673('0x60')]['id']},'transaction':_0x28ac47})[_0x9673('0x21')](function(_0x54806f){return db['VoiceExtension']['bulkCreate'](createExtensionsReciveFax(_[_0x9673('0x73')](_0x39e9e0[_0x9673('0x60')],[_0x9673('0xa0'),_0x9673('0x40'),_0x9673('0xa1'),_0x9673('0xa2'),_0x9673('0xa3'),'ListId'])),{'transaction':_0x28ac47});});});})[_0x9673('0x21')](function(){return db['FaxAccount'][_0x9673('0xa4')](_0x39e9e0[_0x9673('0x60')]['id']);})[_0x9673('0x21')](respondWithResult(_0x1a88a2,null))['catch'](handleError(_0x1a88a2,null));};exports['getMessages']=function(_0x3cff70,_0x3d54a7,_0x4bb283){var _0x2caf40={'raw':!![],'where':{}};var _0x47c050={};var _0x5090f0={'count':0x0,'rows':[]};return db['FaxAccount'][_0x9673('0x67')]({'where':{'id':_0x3cff70['params']['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x3d54a7,null))[_0x9673('0x21')](function(_0x5717f7){if(_0x5717f7){_0x47c050['model']=_[_0x9673('0x56')](db[_0x9673('0xa5')][_0x9673('0x57')]);_0x47c050[_0x9673('0x44')]=_[_0x9673('0x56')](_0x3cff70['query']);_0x47c050[_0x9673('0x45')]=_[_0x9673('0x68')](_0x47c050['model'],_0x47c050[_0x9673('0x44')]);_0x2caf40['attributes']=_[_0x9673('0x68')](_0x47c050[_0x9673('0x41')],qs[_0x9673('0x47')](_0x3cff70['query']['fields']));_0x2caf40['attributes']=_0x2caf40['attributes'][_0x9673('0x48')]?_0x2caf40[_0x9673('0x46')]:_0x47c050[_0x9673('0x41')];if(!_0x3cff70['query'][_0x9673('0x49')]('nolimit')){_0x2caf40[_0x9673('0x32')]=qs[_0x9673('0x32')](_0x3cff70[_0x9673('0x44')]['limit']);_0x2caf40['offset']=qs[_0x9673('0x2f')](_0x3cff70[_0x9673('0x44')]['offset']);}_0x2caf40[_0x9673('0x4a')]=qs[_0x9673('0x4b')](_0x3cff70[_0x9673('0x44')][_0x9673('0x4b')]);_0x2caf40[_0x9673('0x4d')]=qs[_0x9673('0x45')](_[_0x9673('0x69')](_0x3cff70[_0x9673('0x44')],_0x47c050[_0x9673('0x45')]));_0x2caf40['where'][_0x9673('0x64')]=_0x5717f7['id'];if(_0x3cff70[_0x9673('0x44')]['filter']){_0x2caf40['where']=_['merge'](_0x2caf40[_0x9673('0x4d')],{'$or':_[_0x9673('0x42')](_0x2caf40[_0x9673('0x46')],function(_0x41a7a7){var _0x2ad2c4={};_0x2ad2c4[_0x41a7a7]={'$like':'%'+_0x3cff70[_0x9673('0x44')][_0x9673('0x4c')]+'%'};return _0x2ad2c4;})});}if(_0x3cff70[_0x9673('0x44')][_0x9673('0xa6')]){var _0x42bee1=_0x3cff70[_0x9673('0x44')][_0x9673('0xa6')][_0x9673('0xa7')](',');var _0x53f701={};_0x53f701[_0x42bee1[0x0]]={'$gte':moment(_0x42bee1[0x1])[_0x9673('0xa8')](_0x9673('0xa9'))};_0x2caf40[_0x9673('0x4d')]=_[_0x9673('0x4f')](_0x2caf40[_0x9673('0x4d')],_0x53f701);}_0x2caf40=_[_0x9673('0x4f')]({},_0x2caf40,_0x3cff70[_0x9673('0x58')]);return db[_0x9673('0xa5')][_0x9673('0x31')]({'where':_0x2caf40[_0x9673('0x4d')]})[_0x9673('0x21')](function(_0xce966d){_0x5090f0[_0x9673('0x31')]=_0xce966d;if(_0x3cff70[_0x9673('0x44')][_0x9673('0x50')]){_0x2caf40['include']=[{'all':!![]}];}return db['FaxMessage']['findAll'](_0x2caf40);})['then'](function(_0x3f4135){_0x5090f0[_0x9673('0x6a')]=_0x3f4135;return _0x5090f0;});}})[_0x9673('0x21')](respondWithFilteredResult(_0x3d54a7,_0x2caf40))[_0x9673('0x53')](handleError(_0x3d54a7,null));};exports[_0x9673('0x3c')]=function(_0x5b6ae5,_0x5a2a65,_0x315317){var _0x28c154,_0x301b09={},_0x33243d;if(_0x5b6ae5[_0x9673('0x60')]['to']){_0x33243d=_0x5b6ae5[_0x9673('0x60')]['to'][0x0];}return db[_0x9673('0x3e')][_0x9673('0x59')]({'where':{'id':_0x5b6ae5['params']['id']},'include':[{'model':db[_0x9673('0xaa')],'as':_0x9673('0xab'),'include':[{'model':db[_0x9673('0x75')],'as':_0x9673('0xac'),'where':{'fax':_0x33243d},'limit':0x1,'order':[[_0x9673('0xa2'),_0x9673('0xad')]]}]}]})['then'](handleEntityNotFound(_0x5a2a65,null))['then'](function(_0xf2abc7){_0x28c154=_0xf2abc7;if(_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')]&&_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][_0x9673('0x48')]){for(var _0xbcca6b=0x0;_0xbcca6b<_0x5b6ae5[_0x9673('0x60')]['attachments'][_0x9673('0x48')];_0xbcca6b+=0x1){_0x5b6ae5['body'][_0x9673('0xae')][_0xbcca6b]={'filename':_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][_0xbcca6b][_0x9673('0x43')],'id':_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][_0xbcca6b]['id'],'path':path['join'](config[_0x9673('0xaf')],'server/files/attachments',_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][_0xbcca6b][_0x9673('0xb0')])};}}return respondWithRpcPromise(_0x9673('0xb1'),_0x9673('0xb1'),{'FaxAccountId':_[_0x9673('0xb2')](_0x5b6ae5[_0x9673('0x61')]['id'])?undefined:_0x5b6ae5[_0x9673('0x61')]['id'],'path':_[_0x9673('0xb2')](_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][0x0][_0x9673('0x5')])?undefined:_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][0x0][_0x9673('0x5')],'fax':_[_0x9673('0xb2')](_0x5b6ae5[_0x9673('0x60')]['to'][0x0])?undefined:_0x5b6ae5[_0x9673('0x60')]['to'][0x0]},client9002);})[_0x9673('0x21')](function(){if(_0x28c154){if(_[_0x9673('0xb2')](_0x5b6ae5[_0x9673('0x60')]['from'])){_0x5b6ae5['body']['from']=util[_0x9673('0xa8')](_0x9673('0xb3'),_0x28c154[_0x9673('0x43')],_0x28c154[_0x9673('0xb4')]);}if(_0x28c154[_0x9673('0xab')]){if(_0x28c154[_0x9673('0xab')][_0x9673('0xac')][_0x9673('0x48')]){return _0x28c154['List'][_0x9673('0xac')][0x0];}else{return db['CmContact']['create'](_[_0x9673('0xb5')](_0x5b6ae5[_0x9673('0x60')],{'firstName':_0x5b6ae5['body']['to'][0x0],'phone':_0x5b6ae5[_0x9673('0x60')]['to'][0x0],'fax':_0x5b6ae5['body']['to'][0x0],'ListId':_0x28c154[_0x9673('0xb6')]}));}}else{throw new Error(_0x9673('0xb7'));}}else{throw new Error(_0x9673('0xb8'));}})[_0x9673('0x21')](function(_0x110368){if(_0x110368){return db[_0x9673('0x72')][_0x9673('0x59')]({'where':{'ContactId':_0x110368['id'],'closed':![],'FaxAccountId':_0x28c154['id']}})['then'](function(_0x158698){if(_0x158698){return[_0x158698,![]];}return db[_0x9673('0x72')]['create']({'UserId':_0x5b6ae5[_0x9673('0x5b')]['id'],'ContactId':_0x110368['id'],'FaxAccountId':_0x28c154['id'],'fax':_0x5b6ae5[_0x9673('0x60')]['to'][0x0],'firstMsgDirection':'out','Messages':[_[_0x9673('0x4f')](_0x5b6ae5['body'],{'read':![],'body':_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][0x0]['filename'],'FaxAccountId':_0x28c154['id'],'UserId':_0x5b6ae5[_0x9673('0x5b')]['id'],'ContactId':_0x110368['id'],'AttachmentId':_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][0x0]['id']})]},{'include':[{'model':db['FaxMessage'],'as':_0x9673('0xb9')}]})['then'](function(_0x21ebf0){return[_0x21ebf0,!![]];});});}else{throw new Error(_0x9673('0xba'));}})[_0x9673('0xbb')](function(_0xdea74a,_0x29858d){if(_0x29858d){return _0xdea74a;}return db['FaxMessage'][_0x9673('0x5a')]({'direction':_0x9673('0xbc'),'read':![],'body':_0x5b6ae5[_0x9673('0x60')]['attachments'][0x0][_0x9673('0xbd')],'FaxAccountId':_0x28c154['id'],'FaxInteractionId':_0xdea74a['id'],'UserId':_0x5b6ae5[_0x9673('0x5b')]['id'],'ContactId':_0xdea74a[_0x9673('0xbe')],'AttachmentId':_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][0x0]['id']})[_0x9673('0x21')](function(_0x472beb){_0xdea74a['dataValues'][_0x9673('0xb9')]=[];_0xdea74a[_0x9673('0xbf')][_0x9673('0xb9')]['push'](_0x472beb[_0x9673('0xbf')]);return _0xdea74a;});})[_0x9673('0x21')](function(_0x474b2b){respondWithRpcPromise(_0x9673('0xc0'),'SendFax',{'FaxAccountId':_[_0x9673('0xb2')](_0x5b6ae5[_0x9673('0x61')]['id'])?undefined:_0x5b6ae5[_0x9673('0x61')]['id'],'path':_[_0x9673('0xb2')](_0x5b6ae5[_0x9673('0x60')][_0x9673('0xae')][0x0][_0x9673('0x5')])?undefined:_0x5b6ae5['body'][_0x9673('0xae')][0x0]['path'],'fax':_[_0x9673('0xb2')](_0x5b6ae5[_0x9673('0x60')]['to'][0x0])?undefined:_0x5b6ae5['body']['to'][0x0],'AttachmentId':_0x5b6ae5[_0x9673('0x60')]['attachments'][0x0]['id']},client9002)['then'](function(_0xb13376){logger[_0x9673('0x2a')](_0x9673('0xc1'),_0xb13376);})['catch'](function(_0x3ca4fd){logger[_0x9673('0x2a')]('SendFaxRpc,\x20%s',_0x3ca4fd);});return _0x474b2b;})['then'](respondWithResult(_0x5a2a65,null))[_0x9673('0x53')](handleError(_0x5a2a65,null));};exports[_0x9673('0xc2')]=function(_0x3f88b7,_0x2417a9,_0x2057fc){return db['FaxAccount'][_0x9673('0x59')]({'where':{'id':_0x3f88b7[_0x9673('0x61')]['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x2417a9,null))[_0x9673('0x21')](function(_0x45734d){if(_0x45734d){return _0x45734d[_0x9673('0xc2')](_0x3f88b7[_0x9673('0x60')][_0x9673('0x70')],_[_0x9673('0x73')](_0x3f88b7[_0x9673('0x60')],[_0x9673('0x70'),'id'])||{})[_0x9673('0xbb')](function(_0x4fb16d){for(var _0x116f6d=0x0;_0x116f6d<_0x3f88b7[_0x9673('0x60')][_0x9673('0x70')][_0x9673('0x48')];_0x116f6d+=0x1){socket['emit'](_0x9673('0xc3'),{'UserId':Number(_0x3f88b7[_0x9673('0x60')]['ids'][_0x116f6d]),'FaxAccountId':Number(_0x3f88b7['params']['id'])});}return _0x4fb16d;});}})['then'](respondWithResult(_0x2417a9,null))[_0x9673('0x53')](handleError(_0x2417a9,null));};exports['removeAgents']=function(_0x588d54,_0x37fcf4,_0x32ad53){return db['FaxAccount'][_0x9673('0x59')]({'where':{'id':_0x588d54[_0x9673('0x61')]['id']}})[_0x9673('0x21')](handleEntityNotFound(_0x37fcf4,null))[_0x9673('0x21')](function(_0x119a81){if(_0x119a81){return _0x119a81[_0x9673('0xc4')](_0x588d54['query'][_0x9673('0x70')])[_0x9673('0x21')](function(){if(_[_0x9673('0xc5')](_0x588d54['query'][_0x9673('0x70')])){for(var _0x2ca301=0x0;_0x2ca301<_0x588d54[_0x9673('0x44')]['ids'][_0x9673('0x48')];_0x2ca301+=0x1){socket['emit'](_0x9673('0xc6'),{'UserId':Number(_0x588d54[_0x9673('0x44')]['ids'][_0x2ca301]),'FaxAccountId':Number(_0x588d54[_0x9673('0x61')]['id'])});}}else{socket['emit']('userFaxAccount:remove',{'UserId':Number(_0x588d54[_0x9673('0x44')][_0x9673('0x70')]),'FaxAccountId':Number(_0x588d54[_0x9673('0x61')]['id'])});}});}})[_0x9673('0x21')](respondWithStatusCode(_0x37fcf4,null))['catch'](handleError(_0x37fcf4,null));};exports[_0x9673('0xc7')]=function(_0x1bb7dd,_0x53f9b8,_0x389e3e){var _0x406a0d={};var _0x24851f={};var _0xabd656;var _0x497cf4;return db[_0x9673('0x3e')][_0x9673('0x67')]({'where':{'id':_0x1bb7dd[_0x9673('0x61')]['id']}})['then'](handleEntityNotFound(_0x53f9b8,null))[_0x9673('0x21')](function(_0x2a8ce0){if(_0x2a8ce0){_0xabd656=_0x2a8ce0;_0x24851f[_0x9673('0x41')]=_[_0x9673('0x56')](db[_0x9673('0x77')][_0x9673('0x57')]);_0x24851f[_0x9673('0x44')]=_[_0x9673('0x56')](_0x1bb7dd[_0x9673('0x44')]);_0x24851f[_0x9673('0x45')]=_[_0x9673('0x68')](_0x24851f[_0x9673('0x41')],_0x24851f['query']);_0x406a0d['attributes']=_[_0x9673('0x68')](_0x24851f[_0x9673('0x41')],qs[_0x9673('0x47')](_0x1bb7dd[_0x9673('0x44')][_0x9673('0x47')]));_0x406a0d[_0x9673('0x46')]=_0x406a0d[_0x9673('0x46')]['length']?_0x406a0d[_0x9673('0x46')]:_0x24851f[_0x9673('0x41')];_0x406a0d[_0x9673('0x4a')]=qs['sort'](_0x1bb7dd['query'][_0x9673('0x4b')]);_0x406a0d[_0x9673('0x4d')]=qs['filters'](_[_0x9673('0x69')](_0x1bb7dd[_0x9673('0x44')],_0x24851f[_0x9673('0x45')]));if(_0x1bb7dd['query'][_0x9673('0x4c')]){_0x406a0d[_0x9673('0x4d')]=_['merge'](_0x406a0d['where'],{'$or':_[_0x9673('0x42')](_0x406a0d[_0x9673('0x46')],function(_0x272765){var _0x1c6a1f={};_0x1c6a1f[_0x272765]={'$like':'%'+_0x1bb7dd[_0x9673('0x44')][_0x9673('0x4c')]+'%'};return _0x1c6a1f;})});}_0x406a0d=_[_0x9673('0x4f')]({},_0x406a0d,_0x1bb7dd[_0x9673('0x58')]);return _0xabd656[_0x9673('0xc7')](_0x406a0d);}})[_0x9673('0x21')](function(_0x4010c8){if(_0x4010c8){_0x497cf4=_0x4010c8[_0x9673('0x48')];if(!_0x1bb7dd[_0x9673('0x44')][_0x9673('0x49')](_0x9673('0x6e'))){_0x406a0d[_0x9673('0x32')]=qs[_0x9673('0x32')](_0x1bb7dd[_0x9673('0x44')][_0x9673('0x32')]);_0x406a0d['offset']=qs[_0x9673('0x2f')](_0x1bb7dd[_0x9673('0x44')][_0x9673('0x2f')]);}return _0xabd656[_0x9673('0xc7')](_0x406a0d);}})['then'](function(_0x47402f){if(_0x47402f){return _0x47402f?{'count':_0x497cf4,'rows':_0x47402f}:null;}})[_0x9673('0x21')](respondWithResult(_0x53f9b8,null))['catch'](handleError(_0x53f9b8,null));};
\ No newline at end of file