Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index 08c54b4..8b37dc9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3d22=['../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','defaults','localhost','register','jayson/promise','http','request','then','info','request\x20sent','stringify','error','code','FaxAccount,\x20%s,\x20%s','message','result','catch','sendStatus','status','json','offset','undefined','limit','Content-Range','apply','save','update','destroy','get','UserProfileResource','end','stack','name','send','Pause','map','FaxAccount','rawAttributes','fieldName','model','query','filters','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','count','includeAll','include','findAll','rows','params','mandatoryDispositionPause','keys','intersection','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','FaxAccounts','UserProfileSection','find','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','Disposition','findOne','hasOwnProperty','FaxAccountId','removeDispositions','addAnswer','CannedAnswer','removeAnswers','FaxInteraction','addInteraction','ids','omit','getInteractions','User','Owner','internal','Tag','Tags','color','tag','addApplications','sequelize','transaction','ISOLATION_LEVELS','READ_COMMITTED','FaxApplication','bulkCreate','findAndCountAll','priority','getApplications','context','exten','localstationid','app','system','description','appdata','push','Answer','ecm','faxdetect','headerinfo','maxrate','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','addAccountApplications','VoiceExtension','updateAccountApplications','tech','key','createdAt','updatedAt','TrunkId','ListId','findById','FaxMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','Contacts','DESC','attachments','join','server/files/attachments','basename','CheckAfterSend','isNil','\x22%s\x22\x20<%s>','CmContact','List\x20not\x20found','Send\x20Fax\x20failed','out','filename','spread','ContactId','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','emit','userFaxAccount:save','removeAgents','userFaxAccount:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service'];(function(_0x26284f,_0x22577a){var _0xf0d62c=function(_0x57e801){while(--_0x57e801){_0x26284f['push'](_0x26284f['shift']());}};_0xf0d62c(++_0x22577a);}(_0x3d22,0xad));var _0x23d2=function(_0x3a25e6,_0x5ad935){_0x3a25e6=_0x3a25e6-0x0;var _0x5a173a=_0x3d22[_0x3a25e6];return _0x5a173a;};'use strict';var emlformat=require(_0x23d2('0x0'));var rimraf=require(_0x23d2('0x1'));var zipdir=require(_0x23d2('0x2'));var jsonpatch=require(_0x23d2('0x3'));var rp=require('request-promise');var moment=require(_0x23d2('0x4'));var BPromise=require(_0x23d2('0x5'));var Mustache=require(_0x23d2('0x6'));var util=require(_0x23d2('0x7'));var path=require(_0x23d2('0x8'));var sox=require(_0x23d2('0x9'));var csv=require('to-csv');var ejs=require(_0x23d2('0xa'));var fs=require('fs');var fs_extra=require(_0x23d2('0xb'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x23d2('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x23d2('0xd'));var toCsv=require(_0x23d2('0xe'));var querystring=require(_0x23d2('0xf'));var Papa=require(_0x23d2('0x10'));var Redis=require(_0x23d2('0x11'));var authService=require(_0x23d2('0x12'));var qs=require(_0x23d2('0x13'));var as=require(_0x23d2('0x14'));var hardwareService=require(_0x23d2('0x15'));var logger=require(_0x23d2('0x16'))(_0x23d2('0x17'));var utils=require(_0x23d2('0x18'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x23d2('0x19'))['db'];config[_0x23d2('0x1a')]=_[_0x23d2('0x1b')](config[_0x23d2('0x1a')],{'host':_0x23d2('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./faxAccount.socket')[_0x23d2('0x1d')](socket);var jayson=require(_0x23d2('0x1e'));var client=jayson['client']['http']({'port':0x232c});var client9002=jayson['client'][_0x23d2('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x5a4aa1,_0x3e9deb,_0x4a2354,_0x15e34f){return new BPromise(function(_0x535469,_0x14e9e6){var _0x534920=_0x15e34f||client;return _0x534920[_0x23d2('0x20')](_0x5a4aa1,_0x4a2354)[_0x23d2('0x21')](function(_0x290b27){logger[_0x23d2('0x22')]('FaxAccount,\x20%s,\x20%s',_0x3e9deb,'request\x20sent');logger['debug']('FaxAccount,\x20%s,\x20%s,\x20%s',_0x3e9deb,_0x23d2('0x23'),JSON[_0x23d2('0x24')](_0x290b27));if(_0x290b27[_0x23d2('0x25')]){if(_0x290b27[_0x23d2('0x25')][_0x23d2('0x26')]===0x1f4){logger[_0x23d2('0x25')](_0x23d2('0x27'),_0x3e9deb,_0x290b27['error'][_0x23d2('0x28')]);return _0x14e9e6(_0x290b27[_0x23d2('0x25')][_0x23d2('0x28')]);}logger['error'](_0x23d2('0x27'),_0x3e9deb,_0x290b27[_0x23d2('0x25')]['message']);return _0x535469(_0x290b27[_0x23d2('0x25')][_0x23d2('0x28')]);}else{logger[_0x23d2('0x22')]('FaxAccount,\x20%s,\x20%s',_0x3e9deb,_0x23d2('0x23'));_0x535469(_0x290b27[_0x23d2('0x29')][_0x23d2('0x28')]);}})[_0x23d2('0x2a')](function(_0x9a1f67){logger[_0x23d2('0x25')](_0x23d2('0x27'),_0x3e9deb,_0x9a1f67);_0x14e9e6(_0x9a1f67);});});}function respondWithStatusCode(_0x5b5e68,_0x4ef482){_0x4ef482=_0x4ef482||0xcc;return function(_0x31761d){if(_0x31761d){return _0x5b5e68[_0x23d2('0x2b')](_0x4ef482);}return _0x5b5e68[_0x23d2('0x2c')](_0x4ef482)['end']();};}function respondWithResult(_0x2005cb,_0x1be880){_0x1be880=_0x1be880||0xc8;return function(_0x505c26){if(_0x505c26){return _0x2005cb['status'](_0x1be880)[_0x23d2('0x2d')](_0x505c26);}};}function respondWithFilteredResult(_0x120880,_0x2ea14c){return function(_0x168df0){if(_0x168df0){var _0x3dd156=typeof _0x2ea14c[_0x23d2('0x2e')]===_0x23d2('0x2f')&&typeof _0x2ea14c[_0x23d2('0x30')]==='undefined';var _0x1cac4f=_0x168df0['count'];var _0x4e4a37=_0x3dd156?0x0:_0x2ea14c[_0x23d2('0x2e')];var _0x4d8b9a=_0x3dd156?_0x168df0['count']:_0x2ea14c['offset']+_0x2ea14c[_0x23d2('0x30')];var _0x307726;if(_0x4d8b9a>=_0x1cac4f){_0x4d8b9a=_0x1cac4f;_0x307726=0xc8;}else{_0x307726=0xce;}_0x120880[_0x23d2('0x2c')](_0x307726);return _0x120880['set'](_0x23d2('0x31'),_0x4e4a37+'-'+_0x4d8b9a+'/'+_0x1cac4f)['json'](_0x168df0);}return null;};}function patchUpdates(_0x17c854){return function(_0x2d8269){try{jsonpatch[_0x23d2('0x32')](_0x2d8269,_0x17c854,!![]);}catch(_0xf0456b){return BPromise['reject'](_0xf0456b);}return _0x2d8269[_0x23d2('0x33')]();};}function saveUpdates(_0x40aa00,_0x179817){return function(_0x222b73){if(_0x222b73){return _0x222b73[_0x23d2('0x34')](_0x40aa00)[_0x23d2('0x21')](function(_0x3a7e11){return _0x3a7e11;});}return null;};}function removeEntity(_0x10aeb5,_0x5d4d23){return function(_0x1cb43b){if(_0x1cb43b){return _0x1cb43b[_0x23d2('0x35')]()[_0x23d2('0x21')](function(){var _0x280ccd=_0x1cb43b[_0x23d2('0x36')]({'plain':!![]});var _0xdfcc53='FaxAccounts';return db[_0x23d2('0x37')]['destroy']({'where':{'type':_0xdfcc53,'resourceId':_0x280ccd['id']}})[_0x23d2('0x21')](function(){return _0x1cb43b;});})['then'](function(){_0x10aeb5[_0x23d2('0x2c')](0xcc)[_0x23d2('0x38')]();});}};}function handleEntityNotFound(_0x14bfce,_0x26e88b){return function(_0x11f87a){if(!_0x11f87a){_0x14bfce['sendStatus'](0x194);}return _0x11f87a;};}function handleError(_0x480963,_0x572887){_0x572887=_0x572887||0x1f4;return function(_0x45001c){logger[_0x23d2('0x25')](_0x45001c[_0x23d2('0x39')]);if(_0x45001c['name']){delete _0x45001c[_0x23d2('0x3a')];}_0x480963[_0x23d2('0x2c')](_0x572887)[_0x23d2('0x3b')](_0x45001c);};}exports['index']=function(_0x3c160b,_0x3be0b9){var _0x58bc62={'include':[{'model':db[_0x23d2('0x3c')],'as':'mandatoryDispositionPause'}]},_0x247fd1={},_0xcc4214={'count':0x0,'rows':[]};var _0x18c1ef=_[_0x23d2('0x3d')](db[_0x23d2('0x3e')][_0x23d2('0x3f')],function(_0x3f8105){return{'name':_0x3f8105[_0x23d2('0x40')],'type':_0x3f8105['type']['key']};});_0x247fd1[_0x23d2('0x41')]=_[_0x23d2('0x3d')](_0x18c1ef,_0x23d2('0x3a'));_0x247fd1[_0x23d2('0x42')]=_['keys'](_0x3c160b[_0x23d2('0x42')]);_0x247fd1[_0x23d2('0x43')]=_['intersection'](_0x247fd1[_0x23d2('0x41')],_0x247fd1[_0x23d2('0x42')]);_0x58bc62[_0x23d2('0x44')]=_['intersection'](_0x247fd1[_0x23d2('0x41')],qs[_0x23d2('0x45')](_0x3c160b[_0x23d2('0x42')][_0x23d2('0x45')]));_0x58bc62[_0x23d2('0x44')]=_0x58bc62[_0x23d2('0x44')][_0x23d2('0x46')]?_0x58bc62[_0x23d2('0x44')]:_0x247fd1[_0x23d2('0x41')];if(!_0x3c160b[_0x23d2('0x42')]['hasOwnProperty'](_0x23d2('0x47'))){_0x58bc62[_0x23d2('0x30')]=qs[_0x23d2('0x30')](_0x3c160b[_0x23d2('0x42')][_0x23d2('0x30')]);_0x58bc62[_0x23d2('0x2e')]=qs['offset'](_0x3c160b[_0x23d2('0x42')][_0x23d2('0x2e')]);}_0x58bc62[_0x23d2('0x48')]=qs[_0x23d2('0x49')](_0x3c160b[_0x23d2('0x42')][_0x23d2('0x49')]);_0x58bc62[_0x23d2('0x4a')]=qs[_0x23d2('0x43')](_[_0x23d2('0x4b')](_0x3c160b['query'],_0x247fd1[_0x23d2('0x43')]),_0x18c1ef);if(_0x3c160b[_0x23d2('0x42')][_0x23d2('0x4c')]){_0x58bc62['where']=_[_0x23d2('0x4d')](_0x58bc62['where'],{'$or':_[_0x23d2('0x3d')](_0x18c1ef,function(_0x3e94e2){if(_0x3e94e2[_0x23d2('0x4e')]!==_0x23d2('0x4f')){var _0x299a7d={};_0x299a7d[_0x3e94e2[_0x23d2('0x3a')]]={'$like':'%'+_0x3c160b['query'][_0x23d2('0x4c')]+'%'};return _0x299a7d;}})});}_0x58bc62=_[_0x23d2('0x4d')]({},_0x58bc62,_0x3c160b[_0x23d2('0x50')]);var _0x52cceb={'where':_0x58bc62[_0x23d2('0x4a')]};return db[_0x23d2('0x3e')][_0x23d2('0x51')](_0x52cceb)['then'](function(_0x136689){_0xcc4214[_0x23d2('0x51')]=_0x136689;if(_0x3c160b[_0x23d2('0x42')][_0x23d2('0x52')]){_0x58bc62[_0x23d2('0x53')]=[{'all':!![]}];}return db[_0x23d2('0x3e')][_0x23d2('0x54')](_0x58bc62);})[_0x23d2('0x21')](function(_0x799239){_0xcc4214[_0x23d2('0x55')]=_0x799239;return _0xcc4214;})[_0x23d2('0x21')](respondWithFilteredResult(_0x3be0b9,_0x58bc62))['catch'](handleError(_0x3be0b9,null));};exports['show']=function(_0x390686,_0xac816e){var _0x5d9701={'raw':![],'where':{'id':_0x390686[_0x23d2('0x56')]['id']},'include':[{'model':db['Pause'],'as':_0x23d2('0x57')}]},_0x19c349={};_0x19c349[_0x23d2('0x41')]=_[_0x23d2('0x58')](db[_0x23d2('0x3e')][_0x23d2('0x3f')]);_0x19c349[_0x23d2('0x42')]=_[_0x23d2('0x58')](_0x390686[_0x23d2('0x42')]);_0x19c349[_0x23d2('0x43')]=_[_0x23d2('0x59')](_0x19c349[_0x23d2('0x41')],_0x19c349[_0x23d2('0x42')]);_0x5d9701[_0x23d2('0x44')]=_[_0x23d2('0x59')](_0x19c349[_0x23d2('0x41')],qs[_0x23d2('0x45')](_0x390686[_0x23d2('0x42')]['fields']));_0x5d9701[_0x23d2('0x44')]=_0x5d9701[_0x23d2('0x44')][_0x23d2('0x46')]?_0x5d9701[_0x23d2('0x44')]:_0x19c349['model'];if(_0x390686[_0x23d2('0x42')][_0x23d2('0x52')]){_0x5d9701[_0x23d2('0x53')]=[{'all':!![]}];}_0x5d9701=_[_0x23d2('0x4d')]({},_0x5d9701,_0x390686[_0x23d2('0x50')]);return db['FaxAccount']['find'](_0x5d9701)['then'](handleEntityNotFound(_0xac816e,null))[_0x23d2('0x21')](respondWithResult(_0xac816e,null))[_0x23d2('0x2a')](handleError(_0xac816e,null));};exports[_0x23d2('0x5a')]=function(_0x28b8c7,_0x177c9f){return db['FaxAccount'][_0x23d2('0x5a')](_0x28b8c7[_0x23d2('0x5b')],{})['then'](function(_0x358295){var _0x577b35=_0x28b8c7[_0x23d2('0x5c')]['get']({'plain':!![]});if(!_0x577b35)throw new Error(_0x23d2('0x5d'));if(_0x577b35[_0x23d2('0x5e')]===_0x23d2('0x5c')){var _0x1ecca4=_0x358295[_0x23d2('0x36')]({'plain':!![]});var _0x39d4f6=_0x23d2('0x5f');return db[_0x23d2('0x60')][_0x23d2('0x61')]({'where':{'name':_0x39d4f6,'userProfileId':_0x577b35['userProfileId']},'raw':!![]})[_0x23d2('0x21')](function(_0x1eae01){if(_0x1eae01&&_0x1eae01['autoAssociation']===0x0){return db[_0x23d2('0x37')]['create']({'name':_0x1ecca4['name'],'resourceId':_0x1ecca4['id'],'type':_0x1eae01['name'],'sectionId':_0x1eae01['id']},{})[_0x23d2('0x21')](function(){return _0x358295;});}else{return _0x358295;}})[_0x23d2('0x2a')](function(_0x199804){logger[_0x23d2('0x25')](_0x23d2('0x62'),_0x199804);throw _0x199804;});}return _0x358295;})['then'](respondWithResult(_0x177c9f,0xc9))[_0x23d2('0x2a')](handleError(_0x177c9f,null));};exports['update']=function(_0x5b8100,_0x20542c){if(_0x5b8100['body']['id']){delete _0x5b8100[_0x23d2('0x5b')]['id'];}return db[_0x23d2('0x3e')][_0x23d2('0x61')]({'where':{'id':_0x5b8100[_0x23d2('0x56')]['id']},'include':[{'model':db[_0x23d2('0x3c')],'as':_0x23d2('0x57')}]})[_0x23d2('0x21')](handleEntityNotFound(_0x20542c,null))[_0x23d2('0x21')](saveUpdates(_0x5b8100[_0x23d2('0x5b')],null))[_0x23d2('0x21')](respondWithResult(_0x20542c,null))[_0x23d2('0x2a')](handleError(_0x20542c,null));};exports[_0x23d2('0x35')]=function(_0x21401e,_0x82e818){return db[_0x23d2('0x3e')][_0x23d2('0x61')]({'where':{'id':_0x21401e[_0x23d2('0x56')]['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x82e818,null))[_0x23d2('0x21')](removeEntity(_0x82e818,null))['catch'](handleError(_0x82e818,null));};exports[_0x23d2('0x63')]=function(_0xa58312,_0x252654){return db[_0x23d2('0x3e')][_0x23d2('0x63')]()[_0x23d2('0x21')](respondWithResult(_0x252654,null))[_0x23d2('0x2a')](handleError(_0x252654,null));};exports[_0x23d2('0x64')]=function(_0x383768,_0xf857fc,_0xd06b71){if(_0x383768['body']['id']){delete _0x383768[_0x23d2('0x5b')]['id'];}return db[_0x23d2('0x3e')][_0x23d2('0x61')]({'where':{'id':_0x383768['params']['id']}})['then'](handleEntityNotFound(_0xf857fc,null))[_0x23d2('0x21')](function(_0x47adb1){if(_0x47adb1){_0x383768[_0x23d2('0x5b')]['FaxAccountId']=_0x47adb1['id'];return db[_0x23d2('0x65')][_0x23d2('0x5a')](_0x383768[_0x23d2('0x5b')]);}})[_0x23d2('0x21')](respondWithResult(_0xf857fc,null))[_0x23d2('0x2a')](handleError(_0xf857fc,null));};exports['getDispositions']=function(_0x30a4ac,_0xf0a0b5,_0x4b1029){var _0x3aba86={'raw':![],'where':{}};var _0x29547b={};var _0x4b1b8c={'count':0x0,'rows':[]};return db[_0x23d2('0x3e')][_0x23d2('0x66')]({'where':{'id':_0x30a4ac[_0x23d2('0x56')]['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0xf0a0b5,null))['then'](function(_0x8f02f8){if(_0x8f02f8){_0x29547b[_0x23d2('0x41')]=_['keys'](db['Disposition'][_0x23d2('0x3f')]);_0x29547b['query']=_['keys'](_0x30a4ac[_0x23d2('0x42')]);_0x29547b['filters']=_[_0x23d2('0x59')](_0x29547b['model'],_0x29547b[_0x23d2('0x42')]);_0x3aba86[_0x23d2('0x44')]=_['intersection'](_0x29547b[_0x23d2('0x41')],qs[_0x23d2('0x45')](_0x30a4ac[_0x23d2('0x42')][_0x23d2('0x45')]));_0x3aba86[_0x23d2('0x44')]=_0x3aba86['attributes'][_0x23d2('0x46')]?_0x3aba86[_0x23d2('0x44')]:_0x29547b[_0x23d2('0x41')];if(!_0x30a4ac[_0x23d2('0x42')][_0x23d2('0x67')](_0x23d2('0x47'))){_0x3aba86[_0x23d2('0x30')]=qs[_0x23d2('0x30')](_0x30a4ac['query'][_0x23d2('0x30')]);_0x3aba86['offset']=qs['offset'](_0x30a4ac[_0x23d2('0x42')][_0x23d2('0x2e')]);}_0x3aba86[_0x23d2('0x48')]=qs[_0x23d2('0x49')](_0x30a4ac[_0x23d2('0x42')][_0x23d2('0x49')]);_0x3aba86[_0x23d2('0x4a')]=qs[_0x23d2('0x43')](_[_0x23d2('0x4b')](_0x30a4ac['query'],_0x29547b[_0x23d2('0x43')]));_0x3aba86[_0x23d2('0x4a')][_0x23d2('0x68')]=_0x8f02f8['id'];if(_0x30a4ac['query'][_0x23d2('0x4c')]){_0x3aba86[_0x23d2('0x4a')]=_[_0x23d2('0x4d')](_0x3aba86['where'],{'$or':_[_0x23d2('0x3d')](_0x3aba86[_0x23d2('0x44')],function(_0x4a6d80){var _0x435db5={};_0x435db5[_0x4a6d80]={'$like':'%'+_0x30a4ac[_0x23d2('0x42')][_0x23d2('0x4c')]+'%'};return _0x435db5;})});}_0x3aba86=_[_0x23d2('0x4d')]({},_0x3aba86,_0x30a4ac[_0x23d2('0x50')]);return db[_0x23d2('0x65')][_0x23d2('0x51')]({'where':_0x3aba86[_0x23d2('0x4a')]})[_0x23d2('0x21')](function(_0x2f1b38){_0x4b1b8c[_0x23d2('0x51')]=_0x2f1b38;if(_0x30a4ac[_0x23d2('0x42')]['includeAll']){_0x3aba86[_0x23d2('0x53')]=[{'all':!![]}];}return db[_0x23d2('0x65')][_0x23d2('0x54')](_0x3aba86);})[_0x23d2('0x21')](function(_0x5edfc3){_0x4b1b8c[_0x23d2('0x55')]=_0x5edfc3;return _0x4b1b8c;});}})[_0x23d2('0x21')](respondWithFilteredResult(_0xf0a0b5,_0x3aba86))['catch'](handleError(_0xf0a0b5,null));};exports['removeDispositions']=function(_0x25d0a7,_0x1fc3d,_0x2aa033){return db[_0x23d2('0x3e')]['find']({'where':{'id':_0x25d0a7[_0x23d2('0x56')]['id']}})['then'](handleEntityNotFound(_0x1fc3d,null))['then'](function(_0x1cb8e8){if(_0x1cb8e8){return _0x1cb8e8[_0x23d2('0x69')](_0x25d0a7[_0x23d2('0x42')]['ids']);}})[_0x23d2('0x21')](respondWithStatusCode(_0x1fc3d,null))['catch'](handleError(_0x1fc3d,null));};exports[_0x23d2('0x6a')]=function(_0x470717,_0x28a97d,_0x3dae9b){if(_0x470717[_0x23d2('0x5b')]['id']){delete _0x470717[_0x23d2('0x5b')]['id'];}return db[_0x23d2('0x3e')][_0x23d2('0x61')]({'where':{'id':_0x470717['params']['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x28a97d,null))['then'](function(_0x44f16e){if(_0x44f16e){_0x470717['body']['FaxAccountId']=_0x44f16e['id'];return db[_0x23d2('0x6b')][_0x23d2('0x5a')](_0x470717[_0x23d2('0x5b')]);}})['then'](respondWithResult(_0x28a97d,null))[_0x23d2('0x2a')](handleError(_0x28a97d,null));};exports['getAnswers']=function(_0x50fe6b,_0x121ac1,_0x31dfe6){var _0x202fad={'raw':![],'where':{}};var _0x25f7cd={};var _0x563e35={'count':0x0,'rows':[]};return db[_0x23d2('0x3e')][_0x23d2('0x66')]({'where':{'id':_0x50fe6b[_0x23d2('0x56')]['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x121ac1,null))[_0x23d2('0x21')](function(_0x4cd1c3){if(_0x4cd1c3){_0x25f7cd[_0x23d2('0x41')]=_['keys'](db[_0x23d2('0x6b')][_0x23d2('0x3f')]);_0x25f7cd[_0x23d2('0x42')]=_[_0x23d2('0x58')](_0x50fe6b[_0x23d2('0x42')]);_0x25f7cd[_0x23d2('0x43')]=_[_0x23d2('0x59')](_0x25f7cd['model'],_0x25f7cd['query']);_0x202fad[_0x23d2('0x44')]=_[_0x23d2('0x59')](_0x25f7cd[_0x23d2('0x41')],qs[_0x23d2('0x45')](_0x50fe6b[_0x23d2('0x42')]['fields']));_0x202fad['attributes']=_0x202fad[_0x23d2('0x44')][_0x23d2('0x46')]?_0x202fad[_0x23d2('0x44')]:_0x25f7cd['model'];if(!_0x50fe6b['query'][_0x23d2('0x67')](_0x23d2('0x47'))){_0x202fad['limit']=qs[_0x23d2('0x30')](_0x50fe6b[_0x23d2('0x42')][_0x23d2('0x30')]);_0x202fad['offset']=qs['offset'](_0x50fe6b[_0x23d2('0x42')]['offset']);}_0x202fad[_0x23d2('0x48')]=qs[_0x23d2('0x49')](_0x50fe6b['query']['sort']);_0x202fad['where']=qs[_0x23d2('0x43')](_[_0x23d2('0x4b')](_0x50fe6b[_0x23d2('0x42')],_0x25f7cd[_0x23d2('0x43')]));_0x202fad['where'][_0x23d2('0x68')]=_0x4cd1c3['id'];if(_0x50fe6b[_0x23d2('0x42')]['filter']){_0x202fad[_0x23d2('0x4a')]=_[_0x23d2('0x4d')](_0x202fad[_0x23d2('0x4a')],{'$or':_[_0x23d2('0x3d')](_0x202fad[_0x23d2('0x44')],function(_0xc3bd18){var _0x16f789={};_0x16f789[_0xc3bd18]={'$like':'%'+_0x50fe6b[_0x23d2('0x42')][_0x23d2('0x4c')]+'%'};return _0x16f789;})});}_0x202fad=_[_0x23d2('0x4d')]({},_0x202fad,_0x50fe6b[_0x23d2('0x50')]);return db[_0x23d2('0x6b')][_0x23d2('0x51')]({'where':_0x202fad[_0x23d2('0x4a')]})[_0x23d2('0x21')](function(_0x30b1b5){_0x563e35['count']=_0x30b1b5;if(_0x50fe6b[_0x23d2('0x42')][_0x23d2('0x52')]){_0x202fad['include']=[{'all':!![]}];}return db[_0x23d2('0x6b')][_0x23d2('0x54')](_0x202fad);})[_0x23d2('0x21')](function(_0x38d162){_0x563e35[_0x23d2('0x55')]=_0x38d162;return _0x563e35;});}})[_0x23d2('0x21')](respondWithFilteredResult(_0x121ac1,_0x202fad))[_0x23d2('0x2a')](handleError(_0x121ac1,null));};exports[_0x23d2('0x6c')]=function(_0x584d3e,_0x2d77dc,_0xe6af90){return db[_0x23d2('0x3e')][_0x23d2('0x61')]({'where':{'id':_0x584d3e['params']['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x2d77dc,null))[_0x23d2('0x21')](function(_0xaced03){if(_0xaced03){return _0xaced03[_0x23d2('0x6c')](_0x584d3e[_0x23d2('0x42')]['ids']);}})['then'](respondWithStatusCode(_0x2d77dc,null))[_0x23d2('0x2a')](handleError(_0x2d77dc,null));};exports['addInteraction']=function(_0x44e8f8,_0x25bfe0,_0x30503c){return db[_0x23d2('0x6d')][_0x23d2('0x61')]({'where':{'id':_0x44e8f8['params']['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x25bfe0,null))[_0x23d2('0x21')](function(_0x2942c4){if(_0x2942c4){return _0x2942c4[_0x23d2('0x6e')](_0x44e8f8[_0x23d2('0x5b')][_0x23d2('0x6f')],_[_0x23d2('0x70')](_0x44e8f8[_0x23d2('0x5b')],[_0x23d2('0x6f'),'id'])||{});}})[_0x23d2('0x21')](respondWithResult(_0x25bfe0,null))['catch'](handleError(_0x25bfe0,null));};exports[_0x23d2('0x71')]=function(_0x76d223,_0x3447d9,_0x417919){var _0x3d4829={'raw':![],'where':{}};var _0xbe7385={};var _0x3b711c={'count':0x0,'rows':[]};return db[_0x23d2('0x3e')][_0x23d2('0x66')]({'where':{'id':_0x76d223['params']['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x3447d9,null))[_0x23d2('0x21')](function(_0x3178c6){if(_0x3178c6){_0xbe7385[_0x23d2('0x41')]=_[_0x23d2('0x58')](db[_0x23d2('0x6d')][_0x23d2('0x3f')]);_0xbe7385['query']=_[_0x23d2('0x58')](_0x76d223[_0x23d2('0x42')]);_0xbe7385['filters']=_[_0x23d2('0x59')](_0xbe7385[_0x23d2('0x41')],_0xbe7385[_0x23d2('0x42')]);_0x3d4829[_0x23d2('0x44')]=_[_0x23d2('0x59')](_0xbe7385['model'],qs[_0x23d2('0x45')](_0x76d223['query'][_0x23d2('0x45')]));_0x3d4829[_0x23d2('0x44')]=_0x3d4829[_0x23d2('0x44')]['length']?_0x3d4829[_0x23d2('0x44')]:_0xbe7385['model'];if(!_0x76d223[_0x23d2('0x42')][_0x23d2('0x67')](_0x23d2('0x47'))){_0x3d4829[_0x23d2('0x30')]=qs['limit'](_0x76d223[_0x23d2('0x42')][_0x23d2('0x30')]);_0x3d4829[_0x23d2('0x2e')]=qs['offset'](_0x76d223['query'][_0x23d2('0x2e')]);}_0x3d4829[_0x23d2('0x48')]=qs[_0x23d2('0x49')](_0x76d223[_0x23d2('0x42')][_0x23d2('0x49')]);_0x3d4829['where']=qs[_0x23d2('0x43')](_[_0x23d2('0x4b')](_0x76d223[_0x23d2('0x42')],_0xbe7385[_0x23d2('0x43')]));_0x3d4829[_0x23d2('0x4a')][_0x23d2('0x68')]=_0x3178c6['id'];if(_0x76d223[_0x23d2('0x42')][_0x23d2('0x4c')]){_0x3d4829[_0x23d2('0x4a')]=_[_0x23d2('0x4d')](_0x3d4829[_0x23d2('0x4a')],{'$or':_[_0x23d2('0x3d')](_0x3d4829[_0x23d2('0x44')],function(_0x3138b9){var _0x21a37b={};_0x21a37b[_0x3138b9]={'$like':'%'+_0x76d223[_0x23d2('0x42')]['filter']+'%'};return _0x21a37b;})});}_0x3d4829=_['merge']({},_0x3d4829,_0x76d223[_0x23d2('0x50')]);return db[_0x23d2('0x6d')]['count']({'where':_0x3d4829[_0x23d2('0x4a')]})[_0x23d2('0x21')](function(_0x5f4279){_0x3b711c['count']=_0x5f4279;if(_0x76d223['query'][_0x23d2('0x52')]){_0x3d4829['include']=[{'model':db['CmContact'],'as':'Contact','required':![]},{'model':db[_0x23d2('0x72')],'as':_0x23d2('0x73'),'attributes':['name','fullname',_0x23d2('0x74')],'required':![]},{'model':db[_0x23d2('0x75')],'as':_0x23d2('0x76'),'attributes':['id',_0x23d2('0x3a'),_0x23d2('0x77')],'where':_0x76d223[_0x23d2('0x42')][_0x23d2('0x78')]?{'id':_0x76d223[_0x23d2('0x42')][_0x23d2('0x78')]}:undefined,'required':_0x76d223[_0x23d2('0x42')][_0x23d2('0x78')]?!![]:![]}];}return db[_0x23d2('0x6d')][_0x23d2('0x54')](_0x3d4829);})['then'](function(_0x593759){_0x3b711c[_0x23d2('0x55')]=_0x593759;return _0x3b711c;});}})[_0x23d2('0x21')](respondWithFilteredResult(_0x3447d9,_0x3d4829))[_0x23d2('0x2a')](handleError(_0x3447d9,null));};exports[_0x23d2('0x79')]=function(_0x4cf470,_0x5b2670){var _0x5579b5=_0x4cf470[_0x23d2('0x56')]['id'];var _0x39ef75=_0x4cf470[_0x23d2('0x5b')];var _0x4bb7b1=0xc8;var _0x2b6a16=null;return db[_0x23d2('0x7a')][_0x23d2('0x7b')]({'isolationLevel':db[_0x23d2('0x7a')]['Transaction'][_0x23d2('0x7c')][_0x23d2('0x7d')]},function(_0x3d15db){return db[_0x23d2('0x3e')]['findOne']({'where':{'id':_0x5579b5},'transaction':_0x3d15db})[_0x23d2('0x21')](function(_0x43295d){if(_0x43295d){return db[_0x23d2('0x7e')][_0x23d2('0x35')]({'where':{'FaxAccountId':_0x5579b5},'transaction':_0x3d15db})[_0x23d2('0x21')](function(){var _0x322b70=_[_0x23d2('0x3d')](_0x39ef75,function(_0x5054eb){_0x5054eb[_0x23d2('0x68')]=_0x5579b5;return _0x5054eb;});return db[_0x23d2('0x7e')][_0x23d2('0x7f')](_0x322b70,{'transaction':_0x3d15db});});}else{_0x4bb7b1=0x194;_0x2b6a16=[];}});})[_0x23d2('0x21')](function(){if(_0x4bb7b1!==0x194){return db['FaxApplication'][_0x23d2('0x80')]({'where':{'FaxAccountId':_0x5579b5},'order':_0x23d2('0x81')})[_0x23d2('0x21')](function(_0x4618bf){_0x2b6a16=_0x4618bf;});}})['catch'](function(_0x13bbfa){_0x4bb7b1=0x1f4;logger[_0x23d2('0x25')](_0x13bbfa[_0x23d2('0x39')]);if(_0x13bbfa[_0x23d2('0x3a')]){delete _0x13bbfa[_0x23d2('0x3a')];}_0x2b6a16=_0x13bbfa;})['finally'](function(){if(_0x2b6a16===null){_0x5b2670[_0x23d2('0x2b')](_0x4bb7b1);}else{if(_0x4bb7b1===0x1f4){_0x5b2670[_0x23d2('0x2c')](_0x4bb7b1)[_0x23d2('0x3b')](_0x2b6a16);}else{_0x5b2670['status'](_0x4bb7b1)[_0x23d2('0x2d')](_0x2b6a16);}}});};exports[_0x23d2('0x82')]=function(_0x5daffd,_0x2209a8,_0x1a052d){var _0x5e0b6f={};var _0x4a61ba={};var _0x3491cb;var _0x45a759;return db[_0x23d2('0x3e')][_0x23d2('0x66')]({'where':{'id':_0x5daffd[_0x23d2('0x56')]['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x2209a8,null))['then'](function(_0x5d4873){if(_0x5d4873){_0x3491cb=_0x5d4873;_0x4a61ba['model']=_['keys'](db[_0x23d2('0x7e')][_0x23d2('0x3f')]);_0x4a61ba[_0x23d2('0x42')]=_[_0x23d2('0x58')](_0x5daffd['query']);_0x4a61ba['filters']=_[_0x23d2('0x59')](_0x4a61ba[_0x23d2('0x41')],_0x4a61ba[_0x23d2('0x42')]);_0x5e0b6f[_0x23d2('0x44')]=_['intersection'](_0x4a61ba[_0x23d2('0x41')],qs[_0x23d2('0x45')](_0x5daffd[_0x23d2('0x42')][_0x23d2('0x45')]));_0x5e0b6f['attributes']=_0x5e0b6f[_0x23d2('0x44')]['length']?_0x5e0b6f[_0x23d2('0x44')]:_0x4a61ba['model'];_0x5e0b6f['order']=qs[_0x23d2('0x49')](_0x5daffd['query']['sort']);_0x5e0b6f[_0x23d2('0x4a')]=qs[_0x23d2('0x43')](_[_0x23d2('0x4b')](_0x5daffd[_0x23d2('0x42')],_0x4a61ba[_0x23d2('0x43')]));if(_0x5daffd[_0x23d2('0x42')][_0x23d2('0x4c')]){_0x5e0b6f[_0x23d2('0x4a')]=_[_0x23d2('0x4d')](_0x5e0b6f[_0x23d2('0x4a')],{'$or':_['map'](_0x5e0b6f[_0x23d2('0x44')],function(_0x25c7f4){var _0x5ed4bb={};_0x5ed4bb[_0x25c7f4]={'$like':'%'+_0x5daffd[_0x23d2('0x42')][_0x23d2('0x4c')]+'%'};return _0x5ed4bb;})});}_0x5e0b6f=_['merge']({},_0x5e0b6f,_0x5daffd[_0x23d2('0x50')]);return _0x3491cb[_0x23d2('0x82')](_0x5e0b6f);}})[_0x23d2('0x21')](function(_0x2f2da3){if(_0x2f2da3){_0x45a759=_0x2f2da3[_0x23d2('0x46')];if(!_0x5daffd[_0x23d2('0x42')][_0x23d2('0x67')](_0x23d2('0x47'))){_0x5e0b6f[_0x23d2('0x30')]=qs['limit'](_0x5daffd[_0x23d2('0x42')]['limit']);_0x5e0b6f[_0x23d2('0x2e')]=qs[_0x23d2('0x2e')](_0x5daffd['query'][_0x23d2('0x2e')]);}return _0x3491cb['getApplications'](_0x5e0b6f);}})[_0x23d2('0x21')](function(_0x19f52e){if(_0x19f52e){return _0x19f52e?{'count':_0x45a759,'rows':_0x19f52e}:null;}})[_0x23d2('0x21')](respondWithResult(_0x2209a8,null))['catch'](handleError(_0x2209a8,null));};function Extension(_0x73c6a6,_0x265359,_0x43a64a,_0x408c77){this[_0x23d2('0x83')]='from-voip-provider';this[_0x23d2('0x84')]=_0x73c6a6[_0x23d2('0x85')];this[_0x23d2('0x86')]=_0x408c77;this[_0x23d2('0x4e')]=_0x23d2('0x87');this[_0x23d2('0x88')]='Fax\x20Extension';this[_0x23d2('0x68')]=_0x73c6a6['id'];this[_0x23d2('0x81')]=_0x265359;this[_0x23d2('0x89')]=_0x43a64a;}function createExtensionsReciveFax(_0x1978b7){var _0xe99b2c=0x1;var _0x108439=[];_0x108439[_0x23d2('0x8a')](new Extension(_0x1978b7,_0xe99b2c,'',_0x23d2('0x8b')));_0xe99b2c+=0x1;_0x108439['push'](new Extension(_0x1978b7,_0xe99b2c,'CDR(type)=inbound-fax','Set'));_0xe99b2c+=0x1;for(var _0x5a3e25 in _0x1978b7){if(_0x1978b7[_0x23d2('0x67')](_0x5a3e25)&&(_0x5a3e25===_0x23d2('0x8c')||_0x5a3e25===_0x23d2('0x85')||_0x5a3e25==='gateway'||_0x5a3e25===_0x23d2('0x8d')||_0x5a3e25===_0x23d2('0x8e')||_0x5a3e25===_0x23d2('0x8f')||_0x5a3e25==='minrate'||_0x5a3e25===_0x23d2('0x90')||_0x5a3e25===_0x23d2('0x91'))){_0x108439[_0x23d2('0x8a')](new Extension(_0x1978b7,_0xe99b2c,_0x23d2('0x92')+_0x5a3e25+')='+_0x1978b7[_0x5a3e25],'Set'));_0xe99b2c+=0x1;}}_0x108439[_0x23d2('0x8a')](new Extension(_0x1978b7,_0xe99b2c,'6',_0x23d2('0x93')));_0xe99b2c+=0x1;_0x108439['push'](new Extension(_0x1978b7,_0xe99b2c,_0x23d2('0x94'),_0x23d2('0x95')));_0xe99b2c=0x0;return _0x108439;}exports[_0x23d2('0x96')]=function(_0x25978a,_0x447b05,_0xe4f362){var _0x296542;return db[_0x23d2('0x7a')][_0x23d2('0x7b')](function(_0x11ca29){return db[_0x23d2('0x3e')]['create'](_0x25978a[_0x23d2('0x5b')],{'transaction':_0x11ca29})[_0x23d2('0x21')](function(_0x4d7e21){_0x296542=_0x4d7e21[_0x23d2('0x36')]({'plain':!![]});return db[_0x23d2('0x97')][_0x23d2('0x7f')](createExtensionsReciveFax(_0x296542),{'transaction':_0x11ca29});});})[_0x23d2('0x21')](function(){return _0x296542;})[_0x23d2('0x21')](respondWithResult(_0x447b05,null))['catch'](handleError(_0x447b05,null));};exports[_0x23d2('0x98')]=function(_0x12a3e9,_0x13cbe4,_0x5a9e07){var _0x300abd;return db[_0x23d2('0x7a')][_0x23d2('0x7b')](function(_0x37f578){return db[_0x23d2('0x3e')][_0x23d2('0x34')](_0x12a3e9[_0x23d2('0x5b')],{'where':{'id':_0x12a3e9[_0x23d2('0x5b')]['id']},'transaction':_0x37f578})[_0x23d2('0x21')](function(_0x497c76){return db[_0x23d2('0x97')][_0x23d2('0x35')]({'where':{'FaxAccountId':_0x12a3e9['body']['id']},'transaction':_0x37f578})[_0x23d2('0x21')](function(_0x51ff7a){return db[_0x23d2('0x97')][_0x23d2('0x7f')](createExtensionsReciveFax(_['omit'](_0x12a3e9['body'],[_0x23d2('0x99'),_0x23d2('0x9a'),_0x23d2('0x9b'),_0x23d2('0x9c'),_0x23d2('0x9d'),_0x23d2('0x9e')])),{'transaction':_0x37f578});});});})[_0x23d2('0x21')](function(){return db[_0x23d2('0x3e')][_0x23d2('0x9f')](_0x12a3e9[_0x23d2('0x5b')]['id']);})[_0x23d2('0x21')](respondWithResult(_0x13cbe4,null))[_0x23d2('0x2a')](handleError(_0x13cbe4,null));};exports['getMessages']=function(_0x5c2e80,_0x4a8127,_0x1b69db){var _0x528e21={'raw':!![],'where':{}};var _0x46c0fe={};var _0x319d09={'count':0x0,'rows':[]};return db[_0x23d2('0x3e')][_0x23d2('0x66')]({'where':{'id':_0x5c2e80['params']['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x4a8127,null))[_0x23d2('0x21')](function(_0x88eea6){if(_0x88eea6){_0x46c0fe[_0x23d2('0x41')]=_['keys'](db[_0x23d2('0xa0')][_0x23d2('0x3f')]);_0x46c0fe[_0x23d2('0x42')]=_[_0x23d2('0x58')](_0x5c2e80['query']);_0x46c0fe[_0x23d2('0x43')]=_[_0x23d2('0x59')](_0x46c0fe['model'],_0x46c0fe[_0x23d2('0x42')]);_0x528e21[_0x23d2('0x44')]=_[_0x23d2('0x59')](_0x46c0fe['model'],qs[_0x23d2('0x45')](_0x5c2e80[_0x23d2('0x42')][_0x23d2('0x45')]));_0x528e21[_0x23d2('0x44')]=_0x528e21[_0x23d2('0x44')]['length']?_0x528e21[_0x23d2('0x44')]:_0x46c0fe['model'];if(!_0x5c2e80['query']['hasOwnProperty'](_0x23d2('0x47'))){_0x528e21[_0x23d2('0x30')]=qs[_0x23d2('0x30')](_0x5c2e80[_0x23d2('0x42')]['limit']);_0x528e21[_0x23d2('0x2e')]=qs['offset'](_0x5c2e80['query']['offset']);}_0x528e21[_0x23d2('0x48')]=qs[_0x23d2('0x49')](_0x5c2e80[_0x23d2('0x42')][_0x23d2('0x49')]);_0x528e21[_0x23d2('0x4a')]=qs[_0x23d2('0x43')](_[_0x23d2('0x4b')](_0x5c2e80[_0x23d2('0x42')],_0x46c0fe['filters']));_0x528e21['where'][_0x23d2('0x68')]=_0x88eea6['id'];if(_0x5c2e80['query']['filter']){_0x528e21[_0x23d2('0x4a')]=_[_0x23d2('0x4d')](_0x528e21[_0x23d2('0x4a')],{'$or':_[_0x23d2('0x3d')](_0x528e21[_0x23d2('0x44')],function(_0x279c82){var _0x1ce790={};_0x1ce790[_0x279c82]={'$like':'%'+_0x5c2e80[_0x23d2('0x42')][_0x23d2('0x4c')]+'%'};return _0x1ce790;})});}if(_0x5c2e80['query']['$gte']){var _0xcc3cca=_0x5c2e80[_0x23d2('0x42')][_0x23d2('0xa1')][_0x23d2('0xa2')](',');var _0x5b706e={};_0x5b706e[_0xcc3cca[0x0]]={'$gte':moment(_0xcc3cca[0x1])[_0x23d2('0xa3')](_0x23d2('0xa4'))};_0x528e21[_0x23d2('0x4a')]=_[_0x23d2('0x4d')](_0x528e21[_0x23d2('0x4a')],_0x5b706e);}_0x528e21=_[_0x23d2('0x4d')]({},_0x528e21,_0x5c2e80[_0x23d2('0x50')]);return db[_0x23d2('0xa0')][_0x23d2('0x51')]({'where':_0x528e21[_0x23d2('0x4a')]})[_0x23d2('0x21')](function(_0x38aada){_0x319d09['count']=_0x38aada;if(_0x5c2e80[_0x23d2('0x42')]['includeAll']){_0x528e21[_0x23d2('0x53')]=[{'all':!![]}];}return db[_0x23d2('0xa0')]['findAll'](_0x528e21);})[_0x23d2('0x21')](function(_0x243a61){_0x319d09[_0x23d2('0x55')]=_0x243a61;return _0x319d09;});}})['then'](respondWithFilteredResult(_0x4a8127,_0x528e21))[_0x23d2('0x2a')](handleError(_0x4a8127,null));};exports[_0x23d2('0x3b')]=function(_0x4be5f5,_0xa4a882,_0x24ef52){var _0x43010a,_0xd47422={},_0x18d647;if(_0x4be5f5[_0x23d2('0x5b')]['to']){_0x18d647=_0x4be5f5[_0x23d2('0x5b')]['to'][0x0];}return db['FaxAccount']['find']({'where':{'id':_0x4be5f5[_0x23d2('0x56')]['id']},'include':[{'model':db[_0x23d2('0xa5')],'as':_0x23d2('0xa6'),'include':[{'model':db['CmContact'],'as':_0x23d2('0xa7'),'where':{'fax':_0x18d647},'limit':0x1,'order':[[_0x23d2('0x9c'),_0x23d2('0xa8')]]}]}]})[_0x23d2('0x21')](handleEntityNotFound(_0xa4a882,null))[_0x23d2('0x21')](function(_0x10faab){_0x43010a=_0x10faab;if(_0x4be5f5['body'][_0x23d2('0xa9')]&&_0x4be5f5['body'][_0x23d2('0xa9')][_0x23d2('0x46')]){for(var _0xc28d46=0x0;_0xc28d46<_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')]['length'];_0xc28d46+=0x1){_0x4be5f5[_0x23d2('0x5b')]['attachments'][_0xc28d46]={'filename':_0x4be5f5['body'][_0x23d2('0xa9')][_0xc28d46][_0x23d2('0x3a')],'id':_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][_0xc28d46]['id'],'path':path[_0x23d2('0xaa')](config['root'],_0x23d2('0xab'),_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][_0xc28d46][_0x23d2('0xac')])};}}return respondWithRpcPromise(_0x23d2('0xad'),_0x23d2('0xad'),{'FaxAccountId':_[_0x23d2('0xae')](_0x4be5f5['params']['id'])?undefined:_0x4be5f5['params']['id'],'path':_[_0x23d2('0xae')](_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][0x0][_0x23d2('0x8')])?undefined:_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][0x0][_0x23d2('0x8')],'fax':_['isNil'](_0x4be5f5[_0x23d2('0x5b')]['to'][0x0])?undefined:_0x4be5f5['body']['to'][0x0]},client9002);})[_0x23d2('0x21')](function(){if(_0x43010a){if(_['isNil'](_0x4be5f5[_0x23d2('0x5b')]['from'])){_0x4be5f5[_0x23d2('0x5b')]['from']=util[_0x23d2('0xa3')](_0x23d2('0xaf'),_0x43010a[_0x23d2('0x3a')],_0x43010a['fax']);}if(_0x43010a['List']){if(_0x43010a[_0x23d2('0xa6')][_0x23d2('0xa7')][_0x23d2('0x46')]){return _0x43010a[_0x23d2('0xa6')][_0x23d2('0xa7')][0x0];}else{return db[_0x23d2('0xb0')][_0x23d2('0x5a')](_[_0x23d2('0x1b')](_0x4be5f5['body'],{'firstName':_0x4be5f5[_0x23d2('0x5b')]['to'][0x0],'phone':_0x4be5f5[_0x23d2('0x5b')]['to'][0x0],'fax':_0x4be5f5[_0x23d2('0x5b')]['to'][0x0],'ListId':_0x43010a['ListId']}));}}else{throw new Error(_0x23d2('0xb1'));}}else{throw new Error(_0x23d2('0xb2'));}})[_0x23d2('0x21')](function(_0x4c2007){if(_0x4c2007){return db[_0x23d2('0x6d')][_0x23d2('0x61')]({'where':{'ContactId':_0x4c2007['id'],'closed':![],'FaxAccountId':_0x43010a['id']}})[_0x23d2('0x21')](function(_0x505359){if(_0x505359){return[_0x505359,![]];}return db[_0x23d2('0x6d')][_0x23d2('0x5a')]({'UserId':_0x4be5f5[_0x23d2('0x5c')]['id'],'ContactId':_0x4c2007['id'],'FaxAccountId':_0x43010a['id'],'fax':_0x4be5f5[_0x23d2('0x5b')]['to'][0x0],'firstMsgDirection':_0x23d2('0xb3'),'Messages':[_[_0x23d2('0x4d')](_0x4be5f5[_0x23d2('0x5b')],{'read':![],'body':_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][0x0][_0x23d2('0xb4')],'FaxAccountId':_0x43010a['id'],'UserId':_0x4be5f5[_0x23d2('0x5c')]['id'],'ContactId':_0x4c2007['id'],'AttachmentId':_0x4be5f5[_0x23d2('0x5b')]['attachments'][0x0]['id']})]},{'include':[{'model':db['FaxMessage'],'as':'Messages'}]})[_0x23d2('0x21')](function(_0x5aa2d0){return[_0x5aa2d0,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})[_0x23d2('0xb5')](function(_0x5945f4,_0x556515){if(_0x556515){return _0x5945f4;}return db[_0x23d2('0xa0')][_0x23d2('0x5a')]({'direction':_0x23d2('0xb3'),'read':![],'body':_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][0x0]['filename'],'FaxAccountId':_0x43010a['id'],'FaxInteractionId':_0x5945f4['id'],'UserId':_0x4be5f5['user']['id'],'ContactId':_0x5945f4[_0x23d2('0xb6')],'AttachmentId':_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][0x0]['id']})[_0x23d2('0x21')](function(_0x52a408){_0x5945f4[_0x23d2('0xb7')]['Messages']=[];_0x5945f4['dataValues']['Messages'][_0x23d2('0x8a')](_0x52a408[_0x23d2('0xb7')]);return _0x5945f4;});})[_0x23d2('0x21')](function(_0x25382a){respondWithRpcPromise(_0x23d2('0xb8'),'SendFax',{'FaxAccountId':_[_0x23d2('0xae')](_0x4be5f5[_0x23d2('0x56')]['id'])?undefined:_0x4be5f5[_0x23d2('0x56')]['id'],'path':_['isNil'](_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][0x0][_0x23d2('0x8')])?undefined:_0x4be5f5[_0x23d2('0x5b')][_0x23d2('0xa9')][0x0][_0x23d2('0x8')],'fax':_[_0x23d2('0xae')](_0x4be5f5[_0x23d2('0x5b')]['to'][0x0])?undefined:_0x4be5f5[_0x23d2('0x5b')]['to'][0x0],'AttachmentId':_0x4be5f5['body']['attachments'][0x0]['id']},client9002)[_0x23d2('0x21')](function(_0x3450f3){logger[_0x23d2('0x22')](_0x23d2('0xb9'),_0x3450f3);})[_0x23d2('0x2a')](function(_0x273dfc){logger[_0x23d2('0x22')](_0x23d2('0xb9'),_0x273dfc);});return _0x25382a;})[_0x23d2('0x21')](respondWithResult(_0xa4a882,null))[_0x23d2('0x2a')](handleError(_0xa4a882,null));};exports[_0x23d2('0xba')]=function(_0x370c7f,_0x5a4006,_0x23bea7){return db[_0x23d2('0x3e')]['find']({'where':{'id':_0x370c7f[_0x23d2('0x56')]['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x5a4006,null))[_0x23d2('0x21')](function(_0x18dc36){if(_0x18dc36){return _0x18dc36['addAgents'](_0x370c7f[_0x23d2('0x5b')][_0x23d2('0x6f')],_[_0x23d2('0x70')](_0x370c7f[_0x23d2('0x5b')],['ids','id'])||{})[_0x23d2('0xb5')](function(_0x200cb1){for(var _0x425631=0x0;_0x425631<_0x370c7f[_0x23d2('0x5b')][_0x23d2('0x6f')][_0x23d2('0x46')];_0x425631+=0x1){socket[_0x23d2('0xbb')](_0x23d2('0xbc'),{'UserId':Number(_0x370c7f[_0x23d2('0x5b')]['ids'][_0x425631]),'FaxAccountId':Number(_0x370c7f[_0x23d2('0x56')]['id'])});}return _0x200cb1;});}})['then'](respondWithResult(_0x5a4006,null))[_0x23d2('0x2a')](handleError(_0x5a4006,null));};exports[_0x23d2('0xbd')]=function(_0x295594,_0x59a2a2,_0x33ad3d){return db[_0x23d2('0x3e')][_0x23d2('0x61')]({'where':{'id':_0x295594[_0x23d2('0x56')]['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x59a2a2,null))['then'](function(_0xeed5cc){if(_0xeed5cc){return _0xeed5cc['removeAgents'](_0x295594[_0x23d2('0x42')][_0x23d2('0x6f')])[_0x23d2('0x21')](function(){if(_['isArray'](_0x295594[_0x23d2('0x42')][_0x23d2('0x6f')])){for(var _0x281aae=0x0;_0x281aae<_0x295594['query'][_0x23d2('0x6f')]['length'];_0x281aae+=0x1){socket['emit'](_0x23d2('0xbe'),{'UserId':Number(_0x295594[_0x23d2('0x42')][_0x23d2('0x6f')][_0x281aae]),'FaxAccountId':Number(_0x295594[_0x23d2('0x56')]['id'])});}}else{socket[_0x23d2('0xbb')]('userFaxAccount:remove',{'UserId':Number(_0x295594['query'][_0x23d2('0x6f')]),'FaxAccountId':Number(_0x295594[_0x23d2('0x56')]['id'])});}});}})['then'](respondWithStatusCode(_0x59a2a2,null))['catch'](handleError(_0x59a2a2,null));};exports['getAgents']=function(_0x15a433,_0x489627,_0x190124){var _0x4a6e45={};var _0x1a0cd6={};var _0x3905a4;var _0x3bf5b9;return db[_0x23d2('0x3e')][_0x23d2('0x66')]({'where':{'id':_0x15a433[_0x23d2('0x56')]['id']}})[_0x23d2('0x21')](handleEntityNotFound(_0x489627,null))[_0x23d2('0x21')](function(_0x1d4c1d){if(_0x1d4c1d){_0x3905a4=_0x1d4c1d;_0x1a0cd6[_0x23d2('0x41')]=_['keys'](db[_0x23d2('0x72')][_0x23d2('0x3f')]);_0x1a0cd6[_0x23d2('0x42')]=_[_0x23d2('0x58')](_0x15a433[_0x23d2('0x42')]);_0x1a0cd6[_0x23d2('0x43')]=_[_0x23d2('0x59')](_0x1a0cd6['model'],_0x1a0cd6[_0x23d2('0x42')]);_0x4a6e45[_0x23d2('0x44')]=_[_0x23d2('0x59')](_0x1a0cd6[_0x23d2('0x41')],qs[_0x23d2('0x45')](_0x15a433[_0x23d2('0x42')][_0x23d2('0x45')]));_0x4a6e45[_0x23d2('0x44')]=_0x4a6e45[_0x23d2('0x44')][_0x23d2('0x46')]?_0x4a6e45[_0x23d2('0x44')]:_0x1a0cd6[_0x23d2('0x41')];_0x4a6e45[_0x23d2('0x48')]=qs['sort'](_0x15a433[_0x23d2('0x42')][_0x23d2('0x49')]);_0x4a6e45[_0x23d2('0x4a')]=qs[_0x23d2('0x43')](_[_0x23d2('0x4b')](_0x15a433['query'],_0x1a0cd6[_0x23d2('0x43')]));if(_0x15a433[_0x23d2('0x42')][_0x23d2('0x4c')]){_0x4a6e45[_0x23d2('0x4a')]=_[_0x23d2('0x4d')](_0x4a6e45['where'],{'$or':_['map'](_0x4a6e45['attributes'],function(_0x41a7e9){var _0x44146c={};_0x44146c[_0x41a7e9]={'$like':'%'+_0x15a433['query'][_0x23d2('0x4c')]+'%'};return _0x44146c;})});}_0x4a6e45=_['merge']({},_0x4a6e45,_0x15a433[_0x23d2('0x50')]);return _0x3905a4[_0x23d2('0xbf')](_0x4a6e45);}})[_0x23d2('0x21')](function(_0x5b424a){if(_0x5b424a){_0x3bf5b9=_0x5b424a[_0x23d2('0x46')];if(!_0x15a433[_0x23d2('0x42')][_0x23d2('0x67')](_0x23d2('0x47'))){_0x4a6e45[_0x23d2('0x30')]=qs[_0x23d2('0x30')](_0x15a433['query'][_0x23d2('0x30')]);_0x4a6e45[_0x23d2('0x2e')]=qs['offset'](_0x15a433[_0x23d2('0x42')][_0x23d2('0x2e')]);}return _0x3905a4[_0x23d2('0xbf')](_0x4a6e45);}})[_0x23d2('0x21')](function(_0x2909be){if(_0x2909be){return _0x2909be?{'count':_0x3bf5b9,'rows':_0x2909be}:null;}})['then'](respondWithResult(_0x489627,null))[_0x23d2('0x2a')](handleError(_0x489627,null));};
\ No newline at end of file
+var _0xde36=['format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','Contacts','DESC','attachments','join','server/files/attachments','basename','CheckAfterSend','isNil','path','from','\x22%s\x22\x20<%s>','fax','List\x20not\x20found','out','Contact\x20not\x20found','spread','filename','ContactId','dataValues','Messages','SendFax','SendFaxRpc,\x20%s','addAgents','emit','isArray','userFaxAccount:remove','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','lodash','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','defaults','localhost','socket.io-emitter','redis','register','jayson/promise','client','http','request','info','FaxAccount,\x20%s,\x20%s','request\x20sent','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','update','destroy','then','get','FaxAccounts','UserProfileResource','end','name','send','index','Pause','mandatoryDispositionPause','map','FaxAccount','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','filter','where','merge','type','VIRTUAL','options','includeAll','findAll','rows','show','params','length','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','FaxAccountId','getDispositions','Disposition','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','findOne','removeAnswers','addInteraction','omit','getInteractions','FaxInteraction','pick','CmContact','User','fullname','internal','Tag','Tags','color','tag','addApplications','transaction','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','FaxApplication','bulkCreate','findAndCountAll','priority','stack','finally','getApplications','context','from-voip-provider','exten','localstationid','app','Fax\x20Extension','appdata','push','Answer','Set','ecm','gateway','faxdetect','headerinfo','minrate','modem','t38timeout','FAXOPT(','Wait','VoiceExtension','updateAccountApplications','tech','createdAt','TrunkId','ListId','findById','getMessages','FaxMessage','$gte','split'];(function(_0x55960e,_0x4f4f80){var _0x1b567b=function(_0x123d7f){while(--_0x123d7f){_0x55960e['push'](_0x55960e['shift']());}};_0x1b567b(++_0x4f4f80);}(_0xde36,0x1af));var _0x6de3=function(_0x20f358,_0x44d78b){_0x20f358=_0x20f358-0x0;var _0x46c51c=_0xde36[_0x20f358];return _0x46c51c;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x6de3('0x0'));var zipdir=require(_0x6de3('0x1'));var jsonpatch=require(_0x6de3('0x2'));var rp=require(_0x6de3('0x3'));var moment=require(_0x6de3('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x6de3('0x5'));var util=require(_0x6de3('0x6'));var path=require('path');var sox=require(_0x6de3('0x7'));var csv=require(_0x6de3('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x6de3('0x9'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x6de3('0xa'));var toCsv=require(_0x6de3('0x8'));var querystring=require(_0x6de3('0xb'));var Papa=require(_0x6de3('0xc'));var Redis=require(_0x6de3('0xd'));var authService=require(_0x6de3('0xe'));var qs=require(_0x6de3('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6de3('0x10'));var logger=require(_0x6de3('0x11'))('api');var utils=require(_0x6de3('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x6de3('0x13'))['db'];config['redis']=_[_0x6de3('0x14')](config['redis'],{'host':_0x6de3('0x15'),'port':0x18eb});var socket=require(_0x6de3('0x16'))(new Redis(config[_0x6de3('0x17')]));require('./faxAccount.socket')[_0x6de3('0x18')](socket);var jayson=require(_0x6de3('0x19'));var client=jayson[_0x6de3('0x1a')][_0x6de3('0x1b')]({'port':0x232c});var client9002=jayson[_0x6de3('0x1a')][_0x6de3('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0xeb2535,_0x370da1,_0x59eeab,_0x4f450a){return new BPromise(function(_0x104828,_0x1c2b8b){var _0x51ef88=_0x4f450a||client;return _0x51ef88[_0x6de3('0x1c')](_0xeb2535,_0x59eeab)['then'](function(_0x5e1a32){logger[_0x6de3('0x1d')](_0x6de3('0x1e'),_0x370da1,_0x6de3('0x1f'));logger['debug'](_0x6de3('0x20'),_0x370da1,_0x6de3('0x1f'),JSON[_0x6de3('0x21')](_0x5e1a32));if(_0x5e1a32['error']){if(_0x5e1a32[_0x6de3('0x22')][_0x6de3('0x23')]===0x1f4){logger[_0x6de3('0x22')]('FaxAccount,\x20%s,\x20%s',_0x370da1,_0x5e1a32[_0x6de3('0x22')]['message']);return _0x1c2b8b(_0x5e1a32[_0x6de3('0x22')][_0x6de3('0x24')]);}logger['error']('FaxAccount,\x20%s,\x20%s',_0x370da1,_0x5e1a32[_0x6de3('0x22')][_0x6de3('0x24')]);return _0x104828(_0x5e1a32[_0x6de3('0x22')][_0x6de3('0x24')]);}else{logger[_0x6de3('0x1d')]('FaxAccount,\x20%s,\x20%s',_0x370da1,_0x6de3('0x1f'));_0x104828(_0x5e1a32[_0x6de3('0x25')][_0x6de3('0x24')]);}})[_0x6de3('0x26')](function(_0x3f6d60){logger[_0x6de3('0x22')]('FaxAccount,\x20%s,\x20%s',_0x370da1,_0x3f6d60);_0x1c2b8b(_0x3f6d60);});});}function respondWithStatusCode(_0x3a93a2,_0x1bd760){_0x1bd760=_0x1bd760||0xcc;return function(_0x4be751){if(_0x4be751){return _0x3a93a2[_0x6de3('0x27')](_0x1bd760);}return _0x3a93a2[_0x6de3('0x28')](_0x1bd760)['end']();};}function respondWithResult(_0x5208f9,_0x3c7f1f){_0x3c7f1f=_0x3c7f1f||0xc8;return function(_0x5a43dd){if(_0x5a43dd){return _0x5208f9[_0x6de3('0x28')](_0x3c7f1f)['json'](_0x5a43dd);}};}function respondWithFilteredResult(_0x1d84a5,_0x1fdada){return function(_0x1c0788){if(_0x1c0788){var _0x313b52=typeof _0x1fdada[_0x6de3('0x29')]===_0x6de3('0x2a')&&typeof _0x1fdada[_0x6de3('0x2b')]===_0x6de3('0x2a');var _0xab3551=_0x1c0788[_0x6de3('0x2c')];var _0x5a5663=_0x313b52?0x0:_0x1fdada['offset'];var _0x507250=_0x313b52?_0x1c0788[_0x6de3('0x2c')]:_0x1fdada[_0x6de3('0x29')]+_0x1fdada[_0x6de3('0x2b')];var _0x1b5265;if(_0x507250>=_0xab3551){_0x507250=_0xab3551;_0x1b5265=0xc8;}else{_0x1b5265=0xce;}_0x1d84a5[_0x6de3('0x28')](_0x1b5265);return _0x1d84a5[_0x6de3('0x2d')](_0x6de3('0x2e'),_0x5a5663+'-'+_0x507250+'/'+_0xab3551)[_0x6de3('0x2f')](_0x1c0788);}return null;};}function patchUpdates(_0x4b4464){return function(_0x276813){try{jsonpatch[_0x6de3('0x30')](_0x276813,_0x4b4464,!![]);}catch(_0x3883ab){return BPromise[_0x6de3('0x31')](_0x3883ab);}return _0x276813[_0x6de3('0x32')]();};}function saveUpdates(_0x365d93,_0x2391aa){return function(_0x338bbd){if(_0x338bbd){return _0x338bbd[_0x6de3('0x33')](_0x365d93)['then'](function(_0x4d9abb){return _0x4d9abb;});}return null;};}function removeEntity(_0x425a4f,_0x4320fb){return function(_0x131a42){if(_0x131a42){return _0x131a42[_0x6de3('0x34')]()[_0x6de3('0x35')](function(){var _0xfddf74=_0x131a42[_0x6de3('0x36')]({'plain':!![]});var _0x13fa74=_0x6de3('0x37');return db[_0x6de3('0x38')][_0x6de3('0x34')]({'where':{'type':_0x13fa74,'resourceId':_0xfddf74['id']}})[_0x6de3('0x35')](function(){return _0x131a42;});})[_0x6de3('0x35')](function(){_0x425a4f[_0x6de3('0x28')](0xcc)[_0x6de3('0x39')]();});}};}function handleEntityNotFound(_0x3bab5d,_0x4a8598){return function(_0x45a9b9){if(!_0x45a9b9){_0x3bab5d['sendStatus'](0x194);}return _0x45a9b9;};}function handleError(_0x35b7e3,_0x16bcd5){_0x16bcd5=_0x16bcd5||0x1f4;return function(_0x5e13ea){logger[_0x6de3('0x22')](_0x5e13ea['stack']);if(_0x5e13ea[_0x6de3('0x3a')]){delete _0x5e13ea['name'];}_0x35b7e3['status'](_0x16bcd5)[_0x6de3('0x3b')](_0x5e13ea);};}exports[_0x6de3('0x3c')]=function(_0x5ee15c,_0x2580c4){var _0x110108={'include':[{'model':db[_0x6de3('0x3d')],'as':_0x6de3('0x3e')}]},_0x539e85={},_0x458561={'count':0x0,'rows':[]};var _0x2596ab=_[_0x6de3('0x3f')](db[_0x6de3('0x40')][_0x6de3('0x41')],function(_0x2fa3a4){return{'name':_0x2fa3a4[_0x6de3('0x42')],'type':_0x2fa3a4['type'][_0x6de3('0x43')]};});_0x539e85[_0x6de3('0x44')]=_[_0x6de3('0x3f')](_0x2596ab,_0x6de3('0x3a'));_0x539e85[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x5ee15c['query']);_0x539e85[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x539e85[_0x6de3('0x44')],_0x539e85['query']);_0x110108[_0x6de3('0x49')]=_[_0x6de3('0x48')](_0x539e85[_0x6de3('0x44')],qs['fields'](_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x110108[_0x6de3('0x49')]=_0x110108[_0x6de3('0x49')]['length']?_0x110108[_0x6de3('0x49')]:_0x539e85[_0x6de3('0x44')];if(!_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x110108['limit']=qs['limit'](_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x2b')]);_0x110108['offset']=qs[_0x6de3('0x29')](_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x29')]);}_0x110108[_0x6de3('0x4d')]=qs[_0x6de3('0x4e')](_0x5ee15c['query'][_0x6de3('0x4e')]);_0x110108['where']=qs['filters'](_['pick'](_0x5ee15c[_0x6de3('0x45')],_0x539e85[_0x6de3('0x47')]),_0x2596ab);if(_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x4f')]){_0x110108[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x110108[_0x6de3('0x50')],{'$or':_[_0x6de3('0x3f')](_0x2596ab,function(_0x576a81){if(_0x576a81[_0x6de3('0x52')]!==_0x6de3('0x53')){var _0x5a6911={};_0x5a6911[_0x576a81[_0x6de3('0x3a')]]={'$like':'%'+_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x5a6911;}})});}_0x110108=_['merge']({},_0x110108,_0x5ee15c[_0x6de3('0x54')]);var _0x5d1fd9={'where':_0x110108[_0x6de3('0x50')]};return db[_0x6de3('0x40')][_0x6de3('0x2c')](_0x5d1fd9)['then'](function(_0x42b56c){_0x458561['count']=_0x42b56c;if(_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x55')]){_0x110108['include']=[{'all':!![]}];}return db['FaxAccount'][_0x6de3('0x56')](_0x110108);})[_0x6de3('0x35')](function(_0x4394fb){_0x458561[_0x6de3('0x57')]=_0x4394fb;return _0x458561;})['then'](respondWithFilteredResult(_0x2580c4,_0x110108))[_0x6de3('0x26')](handleError(_0x2580c4,null));};exports[_0x6de3('0x58')]=function(_0x45a34c,_0x5ad112){var _0xeba343={'raw':![],'where':{'id':_0x45a34c[_0x6de3('0x59')]['id']},'include':[{'model':db[_0x6de3('0x3d')],'as':_0x6de3('0x3e')}]},_0x4bd081={};_0x4bd081[_0x6de3('0x44')]=_[_0x6de3('0x46')](db[_0x6de3('0x40')]['rawAttributes']);_0x4bd081[_0x6de3('0x45')]=_['keys'](_0x45a34c['query']);_0x4bd081[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x4bd081[_0x6de3('0x44')],_0x4bd081[_0x6de3('0x45')]);_0xeba343[_0x6de3('0x49')]=_[_0x6de3('0x48')](_0x4bd081[_0x6de3('0x44')],qs['fields'](_0x45a34c[_0x6de3('0x45')][_0x6de3('0x4a')]));_0xeba343[_0x6de3('0x49')]=_0xeba343['attributes'][_0x6de3('0x5a')]?_0xeba343[_0x6de3('0x49')]:_0x4bd081[_0x6de3('0x44')];if(_0x45a34c['query'][_0x6de3('0x55')]){_0xeba343[_0x6de3('0x5b')]=[{'all':!![]}];}_0xeba343=_[_0x6de3('0x51')]({},_0xeba343,_0x45a34c[_0x6de3('0x54')]);return db[_0x6de3('0x40')][_0x6de3('0x5c')](_0xeba343)['then'](handleEntityNotFound(_0x5ad112,null))['then'](respondWithResult(_0x5ad112,null))[_0x6de3('0x26')](handleError(_0x5ad112,null));};exports['create']=function(_0x3ffdd6,_0x573dc8){return db[_0x6de3('0x40')][_0x6de3('0x5d')](_0x3ffdd6[_0x6de3('0x5e')],{})['then'](function(_0x46167c){var _0x6317d8=_0x3ffdd6[_0x6de3('0x5f')][_0x6de3('0x36')]({'plain':!![]});if(!_0x6317d8)throw new Error(_0x6de3('0x60'));if(_0x6317d8[_0x6de3('0x61')]===_0x6de3('0x5f')){var _0x75f614=_0x46167c['get']({'plain':!![]});var _0x21d365=_0x6de3('0x37');return db['UserProfileSection']['find']({'where':{'name':_0x21d365,'userProfileId':_0x6317d8[_0x6de3('0x62')]},'raw':!![]})[_0x6de3('0x35')](function(_0x2001e7){if(_0x2001e7&&_0x2001e7[_0x6de3('0x63')]===0x0){return db[_0x6de3('0x38')][_0x6de3('0x5d')]({'name':_0x75f614[_0x6de3('0x3a')],'resourceId':_0x75f614['id'],'type':_0x2001e7[_0x6de3('0x3a')],'sectionId':_0x2001e7['id']},{})[_0x6de3('0x35')](function(){return _0x46167c;});}else{return _0x46167c;}})[_0x6de3('0x26')](function(_0xfb1bb6){logger[_0x6de3('0x22')](_0x6de3('0x64'),_0xfb1bb6);throw _0xfb1bb6;});}return _0x46167c;})[_0x6de3('0x35')](respondWithResult(_0x573dc8,0xc9))[_0x6de3('0x26')](handleError(_0x573dc8,null));};exports[_0x6de3('0x33')]=function(_0x243465,_0x15de53){if(_0x243465[_0x6de3('0x5e')]['id']){delete _0x243465['body']['id'];}return db['FaxAccount'][_0x6de3('0x5c')]({'where':{'id':_0x243465['params']['id']},'include':[{'model':db[_0x6de3('0x3d')],'as':_0x6de3('0x3e')}]})[_0x6de3('0x35')](handleEntityNotFound(_0x15de53,null))[_0x6de3('0x35')](saveUpdates(_0x243465[_0x6de3('0x5e')],null))[_0x6de3('0x35')](respondWithResult(_0x15de53,null))[_0x6de3('0x26')](handleError(_0x15de53,null));};exports[_0x6de3('0x34')]=function(_0x4fda25,_0x3a447a){return db['FaxAccount']['find']({'where':{'id':_0x4fda25['params']['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x3a447a,null))[_0x6de3('0x35')](removeEntity(_0x3a447a,null))[_0x6de3('0x26')](handleError(_0x3a447a,null));};exports[_0x6de3('0x65')]=function(_0x49a856,_0x196748){return db[_0x6de3('0x40')][_0x6de3('0x65')]()['then'](respondWithResult(_0x196748,null))[_0x6de3('0x26')](handleError(_0x196748,null));};exports[_0x6de3('0x66')]=function(_0x55f641,_0x4413b7,_0x1e593d){if(_0x55f641[_0x6de3('0x5e')]['id']){delete _0x55f641['body']['id'];}return db[_0x6de3('0x40')][_0x6de3('0x5c')]({'where':{'id':_0x55f641[_0x6de3('0x59')]['id']}})['then'](handleEntityNotFound(_0x4413b7,null))[_0x6de3('0x35')](function(_0x2711e7){if(_0x2711e7){_0x55f641[_0x6de3('0x5e')][_0x6de3('0x67')]=_0x2711e7['id'];return db['Disposition'][_0x6de3('0x5d')](_0x55f641[_0x6de3('0x5e')]);}})[_0x6de3('0x35')](respondWithResult(_0x4413b7,null))['catch'](handleError(_0x4413b7,null));};exports[_0x6de3('0x68')]=function(_0x2fa9b1,_0x1622ee,_0x126568){var _0x34443a={'raw':![],'where':{}};var _0x4bc7dc={};var _0x10a4d9={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x2fa9b1[_0x6de3('0x59')]['id']}})['then'](handleEntityNotFound(_0x1622ee,null))[_0x6de3('0x35')](function(_0x251135){if(_0x251135){_0x4bc7dc[_0x6de3('0x44')]=_[_0x6de3('0x46')](db[_0x6de3('0x69')][_0x6de3('0x41')]);_0x4bc7dc[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x2fa9b1[_0x6de3('0x45')]);_0x4bc7dc['filters']=_[_0x6de3('0x48')](_0x4bc7dc[_0x6de3('0x44')],_0x4bc7dc['query']);_0x34443a['attributes']=_[_0x6de3('0x48')](_0x4bc7dc[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0x2fa9b1[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x34443a[_0x6de3('0x49')]=_0x34443a[_0x6de3('0x49')][_0x6de3('0x5a')]?_0x34443a['attributes']:_0x4bc7dc[_0x6de3('0x44')];if(!_0x2fa9b1['query']['hasOwnProperty'](_0x6de3('0x4c'))){_0x34443a[_0x6de3('0x2b')]=qs[_0x6de3('0x2b')](_0x2fa9b1[_0x6de3('0x45')][_0x6de3('0x2b')]);_0x34443a[_0x6de3('0x29')]=qs[_0x6de3('0x29')](_0x2fa9b1[_0x6de3('0x45')]['offset']);}_0x34443a['order']=qs[_0x6de3('0x4e')](_0x2fa9b1[_0x6de3('0x45')][_0x6de3('0x4e')]);_0x34443a[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_['pick'](_0x2fa9b1[_0x6de3('0x45')],_0x4bc7dc[_0x6de3('0x47')]));_0x34443a[_0x6de3('0x50')][_0x6de3('0x67')]=_0x251135['id'];if(_0x2fa9b1['query'][_0x6de3('0x4f')]){_0x34443a[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x34443a['where'],{'$or':_[_0x6de3('0x3f')](_0x34443a[_0x6de3('0x49')],function(_0x1af9f6){var _0x503a40={};_0x503a40[_0x1af9f6]={'$like':'%'+_0x2fa9b1[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x503a40;})});}_0x34443a=_[_0x6de3('0x51')]({},_0x34443a,_0x2fa9b1[_0x6de3('0x54')]);return db[_0x6de3('0x69')]['count']({'where':_0x34443a['where']})[_0x6de3('0x35')](function(_0xb8e339){_0x10a4d9[_0x6de3('0x2c')]=_0xb8e339;if(_0x2fa9b1['query'][_0x6de3('0x55')]){_0x34443a[_0x6de3('0x5b')]=[{'all':!![]}];}return db[_0x6de3('0x69')]['findAll'](_0x34443a);})[_0x6de3('0x35')](function(_0x30bf67){_0x10a4d9[_0x6de3('0x57')]=_0x30bf67;return _0x10a4d9;});}})[_0x6de3('0x35')](respondWithFilteredResult(_0x1622ee,_0x34443a))['catch'](handleError(_0x1622ee,null));};exports['removeDispositions']=function(_0x153553,_0x19deaf,_0x530f80){return db[_0x6de3('0x40')][_0x6de3('0x5c')]({'where':{'id':_0x153553['params']['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x19deaf,null))[_0x6de3('0x35')](function(_0x107c3b){if(_0x107c3b){return _0x107c3b[_0x6de3('0x6a')](_0x153553[_0x6de3('0x45')][_0x6de3('0x6b')]);}})[_0x6de3('0x35')](respondWithStatusCode(_0x19deaf,null))[_0x6de3('0x26')](handleError(_0x19deaf,null));};exports[_0x6de3('0x6c')]=function(_0x4414e4,_0x2e9f8d,_0x5f5b79){if(_0x4414e4[_0x6de3('0x5e')]['id']){delete _0x4414e4[_0x6de3('0x5e')]['id'];}return db[_0x6de3('0x40')][_0x6de3('0x5c')]({'where':{'id':_0x4414e4[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x2e9f8d,null))[_0x6de3('0x35')](function(_0x3596bc){if(_0x3596bc){_0x4414e4[_0x6de3('0x5e')]['FaxAccountId']=_0x3596bc['id'];return db[_0x6de3('0x6d')][_0x6de3('0x5d')](_0x4414e4[_0x6de3('0x5e')]);}})[_0x6de3('0x35')](respondWithResult(_0x2e9f8d,null))[_0x6de3('0x26')](handleError(_0x2e9f8d,null));};exports[_0x6de3('0x6e')]=function(_0x5de66c,_0x36a098,_0x17fc51){var _0x4cc24d={'raw':![],'where':{}};var _0x2596ba={};var _0x55c417={'count':0x0,'rows':[]};return db[_0x6de3('0x40')][_0x6de3('0x6f')]({'where':{'id':_0x5de66c[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x36a098,null))[_0x6de3('0x35')](function(_0x40ecb9){if(_0x40ecb9){_0x2596ba['model']=_[_0x6de3('0x46')](db[_0x6de3('0x6d')][_0x6de3('0x41')]);_0x2596ba[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x5de66c[_0x6de3('0x45')]);_0x2596ba[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x2596ba[_0x6de3('0x44')],_0x2596ba[_0x6de3('0x45')]);_0x4cc24d['attributes']=_[_0x6de3('0x48')](_0x2596ba[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0x5de66c[_0x6de3('0x45')]['fields']));_0x4cc24d[_0x6de3('0x49')]=_0x4cc24d[_0x6de3('0x49')][_0x6de3('0x5a')]?_0x4cc24d['attributes']:_0x2596ba['model'];if(!_0x5de66c[_0x6de3('0x45')]['hasOwnProperty'](_0x6de3('0x4c'))){_0x4cc24d['limit']=qs[_0x6de3('0x2b')](_0x5de66c[_0x6de3('0x45')][_0x6de3('0x2b')]);_0x4cc24d['offset']=qs['offset'](_0x5de66c[_0x6de3('0x45')][_0x6de3('0x29')]);}_0x4cc24d[_0x6de3('0x4d')]=qs[_0x6de3('0x4e')](_0x5de66c[_0x6de3('0x45')][_0x6de3('0x4e')]);_0x4cc24d[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_['pick'](_0x5de66c['query'],_0x2596ba[_0x6de3('0x47')]));_0x4cc24d[_0x6de3('0x50')][_0x6de3('0x67')]=_0x40ecb9['id'];if(_0x5de66c[_0x6de3('0x45')]['filter']){_0x4cc24d[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x4cc24d[_0x6de3('0x50')],{'$or':_[_0x6de3('0x3f')](_0x4cc24d[_0x6de3('0x49')],function(_0x402efb){var _0x54a4bb={};_0x54a4bb[_0x402efb]={'$like':'%'+_0x5de66c[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x54a4bb;})});}_0x4cc24d=_['merge']({},_0x4cc24d,_0x5de66c[_0x6de3('0x54')]);return db[_0x6de3('0x6d')][_0x6de3('0x2c')]({'where':_0x4cc24d[_0x6de3('0x50')]})[_0x6de3('0x35')](function(_0x55c7e9){_0x55c417['count']=_0x55c7e9;if(_0x5de66c['query']['includeAll']){_0x4cc24d[_0x6de3('0x5b')]=[{'all':!![]}];}return db[_0x6de3('0x6d')][_0x6de3('0x56')](_0x4cc24d);})['then'](function(_0x25fe53){_0x55c417[_0x6de3('0x57')]=_0x25fe53;return _0x55c417;});}})[_0x6de3('0x35')](respondWithFilteredResult(_0x36a098,_0x4cc24d))[_0x6de3('0x26')](handleError(_0x36a098,null));};exports['removeAnswers']=function(_0xd3abae,_0xdf1203,_0x1fe2b1){return db['FaxAccount'][_0x6de3('0x5c')]({'where':{'id':_0xd3abae[_0x6de3('0x59')]['id']}})['then'](handleEntityNotFound(_0xdf1203,null))[_0x6de3('0x35')](function(_0x154498){if(_0x154498){return _0x154498[_0x6de3('0x70')](_0xd3abae[_0x6de3('0x45')][_0x6de3('0x6b')]);}})[_0x6de3('0x35')](respondWithStatusCode(_0xdf1203,null))[_0x6de3('0x26')](handleError(_0xdf1203,null));};exports['addInteraction']=function(_0x3f6127,_0x2b0804,_0x1c5a43){return db['FaxInteraction']['find']({'where':{'id':_0x3f6127['params']['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x2b0804,null))[_0x6de3('0x35')](function(_0x15df38){if(_0x15df38){return _0x15df38[_0x6de3('0x71')](_0x3f6127[_0x6de3('0x5e')]['ids'],_[_0x6de3('0x72')](_0x3f6127[_0x6de3('0x5e')],[_0x6de3('0x6b'),'id'])||{});}})[_0x6de3('0x35')](respondWithResult(_0x2b0804,null))[_0x6de3('0x26')](handleError(_0x2b0804,null));};exports[_0x6de3('0x73')]=function(_0x297bdd,_0x118087,_0x3b1b36){var _0x31d47={'raw':![],'where':{}};var _0x2d42d1={};var _0x2575da={'count':0x0,'rows':[]};return db[_0x6de3('0x40')][_0x6de3('0x6f')]({'where':{'id':_0x297bdd[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x118087,null))[_0x6de3('0x35')](function(_0x5d03ac){if(_0x5d03ac){_0x2d42d1[_0x6de3('0x44')]=_[_0x6de3('0x46')](db[_0x6de3('0x74')][_0x6de3('0x41')]);_0x2d42d1[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x297bdd[_0x6de3('0x45')]);_0x2d42d1[_0x6de3('0x47')]=_['intersection'](_0x2d42d1[_0x6de3('0x44')],_0x2d42d1[_0x6de3('0x45')]);_0x31d47[_0x6de3('0x49')]=_[_0x6de3('0x48')](_0x2d42d1['model'],qs[_0x6de3('0x4a')](_0x297bdd[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x31d47['attributes']=_0x31d47['attributes']['length']?_0x31d47['attributes']:_0x2d42d1[_0x6de3('0x44')];if(!_0x297bdd[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x31d47[_0x6de3('0x2b')]=qs[_0x6de3('0x2b')](_0x297bdd['query'][_0x6de3('0x2b')]);_0x31d47[_0x6de3('0x29')]=qs[_0x6de3('0x29')](_0x297bdd[_0x6de3('0x45')][_0x6de3('0x29')]);}_0x31d47['order']=qs['sort'](_0x297bdd['query'][_0x6de3('0x4e')]);_0x31d47[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_[_0x6de3('0x75')](_0x297bdd['query'],_0x2d42d1[_0x6de3('0x47')]));_0x31d47[_0x6de3('0x50')]['FaxAccountId']=_0x5d03ac['id'];if(_0x297bdd[_0x6de3('0x45')][_0x6de3('0x4f')]){_0x31d47[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x31d47['where'],{'$or':_[_0x6de3('0x3f')](_0x31d47['attributes'],function(_0x2c22f8){var _0x5adad4={};_0x5adad4[_0x2c22f8]={'$like':'%'+_0x297bdd[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x5adad4;})});}_0x31d47=_[_0x6de3('0x51')]({},_0x31d47,_0x297bdd[_0x6de3('0x54')]);return db['FaxInteraction'][_0x6de3('0x2c')]({'where':_0x31d47[_0x6de3('0x50')]})['then'](function(_0x28f402){_0x2575da[_0x6de3('0x2c')]=_0x28f402;if(_0x297bdd[_0x6de3('0x45')]['includeAll']){_0x31d47[_0x6de3('0x5b')]=[{'model':db[_0x6de3('0x76')],'as':'Contact','required':![]},{'model':db[_0x6de3('0x77')],'as':'Owner','attributes':[_0x6de3('0x3a'),_0x6de3('0x78'),_0x6de3('0x79')],'required':![]},{'model':db[_0x6de3('0x7a')],'as':_0x6de3('0x7b'),'attributes':['id','name',_0x6de3('0x7c')],'where':_0x297bdd[_0x6de3('0x45')]['tag']?{'id':_0x297bdd[_0x6de3('0x45')][_0x6de3('0x7d')]}:undefined,'required':_0x297bdd[_0x6de3('0x45')]['tag']?!![]:![]}];}return db[_0x6de3('0x74')][_0x6de3('0x56')](_0x31d47);})[_0x6de3('0x35')](function(_0xa7715b){_0x2575da[_0x6de3('0x57')]=_0xa7715b;return _0x2575da;});}})[_0x6de3('0x35')](respondWithFilteredResult(_0x118087,_0x31d47))[_0x6de3('0x26')](handleError(_0x118087,null));};exports[_0x6de3('0x7e')]=function(_0x486b02,_0x31b9e3){var _0x44f508=_0x486b02[_0x6de3('0x59')]['id'];var _0x37e120=_0x486b02[_0x6de3('0x5e')];var _0xa0afc3=0xc8;var _0xb39dd3=null;return db['sequelize'][_0x6de3('0x7f')]({'isolationLevel':db[_0x6de3('0x80')][_0x6de3('0x81')][_0x6de3('0x82')][_0x6de3('0x83')]},function(_0x3a7def){return db['FaxAccount'][_0x6de3('0x6f')]({'where':{'id':_0x44f508},'transaction':_0x3a7def})[_0x6de3('0x35')](function(_0x47dc77){if(_0x47dc77){return db['FaxApplication'][_0x6de3('0x34')]({'where':{'FaxAccountId':_0x44f508},'transaction':_0x3a7def})['then'](function(){var _0x2c8585=_[_0x6de3('0x3f')](_0x37e120,function(_0x5b9a81){_0x5b9a81[_0x6de3('0x67')]=_0x44f508;return _0x5b9a81;});return db[_0x6de3('0x84')][_0x6de3('0x85')](_0x2c8585,{'transaction':_0x3a7def});});}else{_0xa0afc3=0x194;_0xb39dd3=[];}});})['then'](function(){if(_0xa0afc3!==0x194){return db['FaxApplication'][_0x6de3('0x86')]({'where':{'FaxAccountId':_0x44f508},'order':_0x6de3('0x87')})['then'](function(_0x5259eb){_0xb39dd3=_0x5259eb;});}})[_0x6de3('0x26')](function(_0x3a7664){_0xa0afc3=0x1f4;logger[_0x6de3('0x22')](_0x3a7664[_0x6de3('0x88')]);if(_0x3a7664[_0x6de3('0x3a')]){delete _0x3a7664[_0x6de3('0x3a')];}_0xb39dd3=_0x3a7664;})[_0x6de3('0x89')](function(){if(_0xb39dd3===null){_0x31b9e3[_0x6de3('0x27')](_0xa0afc3);}else{if(_0xa0afc3===0x1f4){_0x31b9e3[_0x6de3('0x28')](_0xa0afc3)['send'](_0xb39dd3);}else{_0x31b9e3[_0x6de3('0x28')](_0xa0afc3)[_0x6de3('0x2f')](_0xb39dd3);}}});};exports['getApplications']=function(_0x4c684c,_0x1ff19e,_0x3ca9b8){var _0x33f42d={};var _0x3b36d6={};var _0x3dfafc;var _0x328a24;return db[_0x6de3('0x40')][_0x6de3('0x6f')]({'where':{'id':_0x4c684c['params']['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x1ff19e,null))[_0x6de3('0x35')](function(_0x2e453c){if(_0x2e453c){_0x3dfafc=_0x2e453c;_0x3b36d6['model']=_[_0x6de3('0x46')](db['FaxApplication'][_0x6de3('0x41')]);_0x3b36d6['query']=_[_0x6de3('0x46')](_0x4c684c['query']);_0x3b36d6[_0x6de3('0x47')]=_['intersection'](_0x3b36d6['model'],_0x3b36d6[_0x6de3('0x45')]);_0x33f42d[_0x6de3('0x49')]=_['intersection'](_0x3b36d6[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0x4c684c[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x33f42d[_0x6de3('0x49')]=_0x33f42d[_0x6de3('0x49')]['length']?_0x33f42d[_0x6de3('0x49')]:_0x3b36d6[_0x6de3('0x44')];_0x33f42d[_0x6de3('0x4d')]=qs[_0x6de3('0x4e')](_0x4c684c[_0x6de3('0x45')][_0x6de3('0x4e')]);_0x33f42d[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_[_0x6de3('0x75')](_0x4c684c[_0x6de3('0x45')],_0x3b36d6[_0x6de3('0x47')]));if(_0x4c684c['query'][_0x6de3('0x4f')]){_0x33f42d[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x33f42d[_0x6de3('0x50')],{'$or':_['map'](_0x33f42d[_0x6de3('0x49')],function(_0x2f2787){var _0x367024={};_0x367024[_0x2f2787]={'$like':'%'+_0x4c684c['query'][_0x6de3('0x4f')]+'%'};return _0x367024;})});}_0x33f42d=_[_0x6de3('0x51')]({},_0x33f42d,_0x4c684c[_0x6de3('0x54')]);return _0x3dfafc[_0x6de3('0x8a')](_0x33f42d);}})['then'](function(_0x2d783a){if(_0x2d783a){_0x328a24=_0x2d783a[_0x6de3('0x5a')];if(!_0x4c684c[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x33f42d[_0x6de3('0x2b')]=qs[_0x6de3('0x2b')](_0x4c684c[_0x6de3('0x45')][_0x6de3('0x2b')]);_0x33f42d[_0x6de3('0x29')]=qs['offset'](_0x4c684c[_0x6de3('0x45')]['offset']);}return _0x3dfafc['getApplications'](_0x33f42d);}})[_0x6de3('0x35')](function(_0x26a46a){if(_0x26a46a){return _0x26a46a?{'count':_0x328a24,'rows':_0x26a46a}:null;}})[_0x6de3('0x35')](respondWithResult(_0x1ff19e,null))[_0x6de3('0x26')](handleError(_0x1ff19e,null));};function Extension(_0x5592dd,_0x7615a7,_0x16e003,_0x4a245b){this[_0x6de3('0x8b')]=_0x6de3('0x8c');this[_0x6de3('0x8d')]=_0x5592dd[_0x6de3('0x8e')];this[_0x6de3('0x8f')]=_0x4a245b;this[_0x6de3('0x52')]='system';this['description']=_0x6de3('0x90');this[_0x6de3('0x67')]=_0x5592dd['id'];this[_0x6de3('0x87')]=_0x7615a7;this[_0x6de3('0x91')]=_0x16e003;}function createExtensionsReciveFax(_0x5edcd6){var _0x4fa89f=0x1;var _0x46002f=[];_0x46002f[_0x6de3('0x92')](new Extension(_0x5edcd6,_0x4fa89f,'',_0x6de3('0x93')));_0x4fa89f+=0x1;_0x46002f[_0x6de3('0x92')](new Extension(_0x5edcd6,_0x4fa89f,'CDR(type)=inbound-fax',_0x6de3('0x94')));_0x4fa89f+=0x1;for(var _0x1c2968 in _0x5edcd6){if(_0x5edcd6[_0x6de3('0x4b')](_0x1c2968)&&(_0x1c2968===_0x6de3('0x95')||_0x1c2968===_0x6de3('0x8e')||_0x1c2968===_0x6de3('0x96')||_0x1c2968===_0x6de3('0x97')||_0x1c2968===_0x6de3('0x98')||_0x1c2968==='maxrate'||_0x1c2968===_0x6de3('0x99')||_0x1c2968===_0x6de3('0x9a')||_0x1c2968===_0x6de3('0x9b'))){_0x46002f['push'](new Extension(_0x5edcd6,_0x4fa89f,_0x6de3('0x9c')+_0x1c2968+')='+_0x5edcd6[_0x1c2968],_0x6de3('0x94')));_0x4fa89f+=0x1;}}_0x46002f['push'](new Extension(_0x5edcd6,_0x4fa89f,'6',_0x6de3('0x9d')));_0x4fa89f+=0x1;_0x46002f[_0x6de3('0x92')](new Extension(_0x5edcd6,_0x4fa89f,'/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'));_0x4fa89f=0x0;return _0x46002f;}exports['addAccountApplications']=function(_0x2b6caf,_0x10eab6,_0x7945e9){var _0x4d79f2;return db[_0x6de3('0x80')][_0x6de3('0x7f')](function(_0x2a6507){return db['FaxAccount'][_0x6de3('0x5d')](_0x2b6caf[_0x6de3('0x5e')],{'transaction':_0x2a6507})[_0x6de3('0x35')](function(_0x27c767){_0x4d79f2=_0x27c767['get']({'plain':!![]});return db[_0x6de3('0x9e')][_0x6de3('0x85')](createExtensionsReciveFax(_0x4d79f2),{'transaction':_0x2a6507});});})[_0x6de3('0x35')](function(){return _0x4d79f2;})[_0x6de3('0x35')](respondWithResult(_0x10eab6,null))[_0x6de3('0x26')](handleError(_0x10eab6,null));};exports[_0x6de3('0x9f')]=function(_0x49ce5f,_0x28787b,_0xa39442){var _0x4f0a84;return db['sequelize'][_0x6de3('0x7f')](function(_0x1a1e12){return db['FaxAccount'][_0x6de3('0x33')](_0x49ce5f['body'],{'where':{'id':_0x49ce5f[_0x6de3('0x5e')]['id']},'transaction':_0x1a1e12})[_0x6de3('0x35')](function(_0x4459b1){return db[_0x6de3('0x9e')][_0x6de3('0x34')]({'where':{'FaxAccountId':_0x49ce5f['body']['id']},'transaction':_0x1a1e12})[_0x6de3('0x35')](function(_0x5246a3){return db['VoiceExtension'][_0x6de3('0x85')](createExtensionsReciveFax(_['omit'](_0x49ce5f[_0x6de3('0x5e')],[_0x6de3('0xa0'),_0x6de3('0x43'),_0x6de3('0xa1'),'updatedAt',_0x6de3('0xa2'),_0x6de3('0xa3')])),{'transaction':_0x1a1e12});});});})['then'](function(){return db[_0x6de3('0x40')][_0x6de3('0xa4')](_0x49ce5f[_0x6de3('0x5e')]['id']);})['then'](respondWithResult(_0x28787b,null))[_0x6de3('0x26')](handleError(_0x28787b,null));};exports[_0x6de3('0xa5')]=function(_0xce9e36,_0x5944b9,_0x34f546){var _0x4e6f46={'raw':!![],'where':{}};var _0x1b202a={};var _0xe4b702={'count':0x0,'rows':[]};return db['FaxAccount'][_0x6de3('0x6f')]({'where':{'id':_0xce9e36[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x5944b9,null))['then'](function(_0x4b0c5d){if(_0x4b0c5d){_0x1b202a[_0x6de3('0x44')]=_['keys'](db[_0x6de3('0xa6')][_0x6de3('0x41')]);_0x1b202a[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0xce9e36[_0x6de3('0x45')]);_0x1b202a[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x1b202a['model'],_0x1b202a[_0x6de3('0x45')]);_0x4e6f46[_0x6de3('0x49')]=_['intersection'](_0x1b202a[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0xce9e36['query']['fields']));_0x4e6f46[_0x6de3('0x49')]=_0x4e6f46[_0x6de3('0x49')][_0x6de3('0x5a')]?_0x4e6f46[_0x6de3('0x49')]:_0x1b202a[_0x6de3('0x44')];if(!_0xce9e36[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x4e6f46[_0x6de3('0x2b')]=qs['limit'](_0xce9e36[_0x6de3('0x45')]['limit']);_0x4e6f46[_0x6de3('0x29')]=qs[_0x6de3('0x29')](_0xce9e36['query'][_0x6de3('0x29')]);}_0x4e6f46[_0x6de3('0x4d')]=qs['sort'](_0xce9e36[_0x6de3('0x45')]['sort']);_0x4e6f46['where']=qs[_0x6de3('0x47')](_['pick'](_0xce9e36[_0x6de3('0x45')],_0x1b202a[_0x6de3('0x47')]));_0x4e6f46[_0x6de3('0x50')][_0x6de3('0x67')]=_0x4b0c5d['id'];if(_0xce9e36['query']['filter']){_0x4e6f46[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x4e6f46[_0x6de3('0x50')],{'$or':_[_0x6de3('0x3f')](_0x4e6f46[_0x6de3('0x49')],function(_0x1bc472){var _0x5270e1={};_0x5270e1[_0x1bc472]={'$like':'%'+_0xce9e36[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x5270e1;})});}if(_0xce9e36[_0x6de3('0x45')][_0x6de3('0xa7')]){var _0x185888=_0xce9e36['query'][_0x6de3('0xa7')][_0x6de3('0xa8')](',');var _0x53af42={};_0x53af42[_0x185888[0x0]]={'$gte':moment(_0x185888[0x1])[_0x6de3('0xa9')](_0x6de3('0xaa'))};_0x4e6f46['where']=_[_0x6de3('0x51')](_0x4e6f46[_0x6de3('0x50')],_0x53af42);}_0x4e6f46=_[_0x6de3('0x51')]({},_0x4e6f46,_0xce9e36[_0x6de3('0x54')]);return db[_0x6de3('0xa6')][_0x6de3('0x2c')]({'where':_0x4e6f46['where']})[_0x6de3('0x35')](function(_0x22fc36){_0xe4b702[_0x6de3('0x2c')]=_0x22fc36;if(_0xce9e36[_0x6de3('0x45')][_0x6de3('0x55')]){_0x4e6f46[_0x6de3('0x5b')]=[{'all':!![]}];}return db[_0x6de3('0xa6')][_0x6de3('0x56')](_0x4e6f46);})[_0x6de3('0x35')](function(_0x4be4fd){_0xe4b702[_0x6de3('0x57')]=_0x4be4fd;return _0xe4b702;});}})[_0x6de3('0x35')](respondWithFilteredResult(_0x5944b9,_0x4e6f46))[_0x6de3('0x26')](handleError(_0x5944b9,null));};exports['send']=function(_0xa470f,_0x4a98c0,_0x2f2a63){var _0x5a52c3,_0x4e74d2={},_0xbb436f;if(_0xa470f['body']['to']){_0xbb436f=_0xa470f[_0x6de3('0x5e')]['to'][0x0];}return db['FaxAccount'][_0x6de3('0x5c')]({'where':{'id':_0xa470f['params']['id']},'include':[{'model':db[_0x6de3('0xab')],'as':_0x6de3('0xac'),'include':[{'model':db['CmContact'],'as':_0x6de3('0xad'),'where':{'fax':_0xbb436f},'limit':0x1,'order':[['updatedAt',_0x6de3('0xae')]]}]}]})[_0x6de3('0x35')](handleEntityNotFound(_0x4a98c0,null))[_0x6de3('0x35')](function(_0x5711cf){_0x5a52c3=_0x5711cf;if(_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')]&&_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][_0x6de3('0x5a')]){for(var _0x4682a1=0x0;_0x4682a1<_0xa470f[_0x6de3('0x5e')]['attachments'][_0x6de3('0x5a')];_0x4682a1+=0x1){_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][_0x4682a1]={'filename':_0xa470f[_0x6de3('0x5e')]['attachments'][_0x4682a1][_0x6de3('0x3a')],'id':_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][_0x4682a1]['id'],'path':path[_0x6de3('0xb0')](config['root'],_0x6de3('0xb1'),_0xa470f['body'][_0x6de3('0xaf')][_0x4682a1][_0x6de3('0xb2')])};}}return respondWithRpcPromise(_0x6de3('0xb3'),_0x6de3('0xb3'),{'FaxAccountId':_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x59')]['id'])?undefined:_0xa470f[_0x6de3('0x59')]['id'],'path':_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0][_0x6de3('0xb5')])?undefined:_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0]['path'],'fax':_[_0x6de3('0xb4')](_0xa470f['body']['to'][0x0])?undefined:_0xa470f['body']['to'][0x0]},client9002);})[_0x6de3('0x35')](function(){if(_0x5a52c3){if(_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x5e')][_0x6de3('0xb6')])){_0xa470f['body'][_0x6de3('0xb6')]=util[_0x6de3('0xa9')](_0x6de3('0xb7'),_0x5a52c3[_0x6de3('0x3a')],_0x5a52c3[_0x6de3('0xb8')]);}if(_0x5a52c3['List']){if(_0x5a52c3['List'][_0x6de3('0xad')][_0x6de3('0x5a')]){return _0x5a52c3['List'][_0x6de3('0xad')][0x0];}else{return db[_0x6de3('0x76')][_0x6de3('0x5d')](_[_0x6de3('0x14')](_0xa470f[_0x6de3('0x5e')],{'firstName':_0xa470f[_0x6de3('0x5e')]['to'][0x0],'phone':_0xa470f['body']['to'][0x0],'fax':_0xa470f[_0x6de3('0x5e')]['to'][0x0],'ListId':_0x5a52c3[_0x6de3('0xa3')]}));}}else{throw new Error(_0x6de3('0xb9'));}}else{throw new Error('Send\x20Fax\x20failed');}})[_0x6de3('0x35')](function(_0x451381){if(_0x451381){return db[_0x6de3('0x74')]['find']({'where':{'ContactId':_0x451381['id'],'closed':![],'FaxAccountId':_0x5a52c3['id']}})[_0x6de3('0x35')](function(_0x27d3ba){if(_0x27d3ba){return[_0x27d3ba,![]];}return db[_0x6de3('0x74')][_0x6de3('0x5d')]({'UserId':_0xa470f[_0x6de3('0x5f')]['id'],'ContactId':_0x451381['id'],'FaxAccountId':_0x5a52c3['id'],'fax':_0xa470f['body']['to'][0x0],'firstMsgDirection':_0x6de3('0xba'),'Messages':[_['merge'](_0xa470f['body'],{'read':![],'body':_0xa470f['body'][_0x6de3('0xaf')][0x0]['filename'],'FaxAccountId':_0x5a52c3['id'],'UserId':_0xa470f[_0x6de3('0x5f')]['id'],'ContactId':_0x451381['id'],'AttachmentId':_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0]['id']})]},{'include':[{'model':db['FaxMessage'],'as':'Messages'}]})['then'](function(_0x598681){return[_0x598681,!![]];});});}else{throw new Error(_0x6de3('0xbb'));}})[_0x6de3('0xbc')](function(_0x15147a,_0x4e8d3b){if(_0x4e8d3b){return _0x15147a;}return db['FaxMessage'][_0x6de3('0x5d')]({'direction':_0x6de3('0xba'),'read':![],'body':_0xa470f[_0x6de3('0x5e')]['attachments'][0x0][_0x6de3('0xbd')],'FaxAccountId':_0x5a52c3['id'],'FaxInteractionId':_0x15147a['id'],'UserId':_0xa470f[_0x6de3('0x5f')]['id'],'ContactId':_0x15147a[_0x6de3('0xbe')],'AttachmentId':_0xa470f[_0x6de3('0x5e')]['attachments'][0x0]['id']})[_0x6de3('0x35')](function(_0x37c180){_0x15147a[_0x6de3('0xbf')][_0x6de3('0xc0')]=[];_0x15147a[_0x6de3('0xbf')][_0x6de3('0xc0')][_0x6de3('0x92')](_0x37c180[_0x6de3('0xbf')]);return _0x15147a;});})['then'](function(_0x16418e){respondWithRpcPromise(_0x6de3('0xc1'),_0x6de3('0xc1'),{'FaxAccountId':_['isNil'](_0xa470f[_0x6de3('0x59')]['id'])?undefined:_0xa470f['params']['id'],'path':_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0][_0x6de3('0xb5')])?undefined:_0xa470f[_0x6de3('0x5e')]['attachments'][0x0][_0x6de3('0xb5')],'fax':_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x5e')]['to'][0x0])?undefined:_0xa470f[_0x6de3('0x5e')]['to'][0x0],'AttachmentId':_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0]['id']},client9002)['then'](function(_0x302c61){logger['info'](_0x6de3('0xc2'),_0x302c61);})[_0x6de3('0x26')](function(_0x389afb){logger['info']('SendFaxRpc,\x20%s',_0x389afb);});return _0x16418e;})['then'](respondWithResult(_0x4a98c0,null))[_0x6de3('0x26')](handleError(_0x4a98c0,null));};exports[_0x6de3('0xc3')]=function(_0x433e52,_0xe70949,_0x49c920){return db[_0x6de3('0x40')]['find']({'where':{'id':_0x433e52[_0x6de3('0x59')]['id']}})['then'](handleEntityNotFound(_0xe70949,null))[_0x6de3('0x35')](function(_0x13d300){if(_0x13d300){return _0x13d300[_0x6de3('0xc3')](_0x433e52[_0x6de3('0x5e')][_0x6de3('0x6b')],_[_0x6de3('0x72')](_0x433e52['body'],['ids','id'])||{})[_0x6de3('0xbc')](function(_0x1db16e){for(var _0x496380=0x0;_0x496380<_0x433e52['body'][_0x6de3('0x6b')][_0x6de3('0x5a')];_0x496380+=0x1){socket[_0x6de3('0xc4')]('userFaxAccount:save',{'UserId':Number(_0x433e52['body'][_0x6de3('0x6b')][_0x496380]),'FaxAccountId':Number(_0x433e52[_0x6de3('0x59')]['id'])});}return _0x1db16e;});}})['then'](respondWithResult(_0xe70949,null))[_0x6de3('0x26')](handleError(_0xe70949,null));};exports['removeAgents']=function(_0x3c95dc,_0x575114,_0x1acbe3){return db[_0x6de3('0x40')][_0x6de3('0x5c')]({'where':{'id':_0x3c95dc[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x575114,null))[_0x6de3('0x35')](function(_0x2f466f){if(_0x2f466f){return _0x2f466f['removeAgents'](_0x3c95dc[_0x6de3('0x45')][_0x6de3('0x6b')])[_0x6de3('0x35')](function(){if(_[_0x6de3('0xc5')](_0x3c95dc[_0x6de3('0x45')][_0x6de3('0x6b')])){for(var _0x264e25=0x0;_0x264e25<_0x3c95dc[_0x6de3('0x45')]['ids']['length'];_0x264e25+=0x1){socket['emit'](_0x6de3('0xc6'),{'UserId':Number(_0x3c95dc['query'][_0x6de3('0x6b')][_0x264e25]),'FaxAccountId':Number(_0x3c95dc[_0x6de3('0x59')]['id'])});}}else{socket[_0x6de3('0xc4')](_0x6de3('0xc6'),{'UserId':Number(_0x3c95dc[_0x6de3('0x45')][_0x6de3('0x6b')]),'FaxAccountId':Number(_0x3c95dc[_0x6de3('0x59')]['id'])});}});}})[_0x6de3('0x35')](respondWithStatusCode(_0x575114,null))[_0x6de3('0x26')](handleError(_0x575114,null));};exports['getAgents']=function(_0x514fe7,_0x2f8677,_0x108df6){var _0x28a96a={};var _0x508fd4={};var _0x24d6b4;var _0x4a717a;return db['FaxAccount'][_0x6de3('0x6f')]({'where':{'id':_0x514fe7[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x2f8677,null))[_0x6de3('0x35')](function(_0x4e7395){if(_0x4e7395){_0x24d6b4=_0x4e7395;_0x508fd4['model']=_[_0x6de3('0x46')](db[_0x6de3('0x77')]['rawAttributes']);_0x508fd4[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x514fe7['query']);_0x508fd4[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x508fd4[_0x6de3('0x44')],_0x508fd4[_0x6de3('0x45')]);_0x28a96a['attributes']=_[_0x6de3('0x48')](_0x508fd4[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0x514fe7[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x28a96a[_0x6de3('0x49')]=_0x28a96a[_0x6de3('0x49')][_0x6de3('0x5a')]?_0x28a96a[_0x6de3('0x49')]:_0x508fd4[_0x6de3('0x44')];_0x28a96a[_0x6de3('0x4d')]=qs[_0x6de3('0x4e')](_0x514fe7['query']['sort']);_0x28a96a[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_[_0x6de3('0x75')](_0x514fe7[_0x6de3('0x45')],_0x508fd4[_0x6de3('0x47')]));if(_0x514fe7['query'][_0x6de3('0x4f')]){_0x28a96a['where']=_[_0x6de3('0x51')](_0x28a96a[_0x6de3('0x50')],{'$or':_[_0x6de3('0x3f')](_0x28a96a['attributes'],function(_0x579054){var _0x504eb2={};_0x504eb2[_0x579054]={'$like':'%'+_0x514fe7[_0x6de3('0x45')]['filter']+'%'};return _0x504eb2;})});}_0x28a96a=_[_0x6de3('0x51')]({},_0x28a96a,_0x514fe7[_0x6de3('0x54')]);return _0x24d6b4[_0x6de3('0xc7')](_0x28a96a);}})[_0x6de3('0x35')](function(_0x4d6c86){if(_0x4d6c86){_0x4a717a=_0x4d6c86[_0x6de3('0x5a')];if(!_0x514fe7[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x28a96a[_0x6de3('0x2b')]=qs[_0x6de3('0x2b')](_0x514fe7[_0x6de3('0x45')]['limit']);_0x28a96a[_0x6de3('0x29')]=qs[_0x6de3('0x29')](_0x514fe7[_0x6de3('0x45')][_0x6de3('0x29')]);}return _0x24d6b4[_0x6de3('0xc7')](_0x28a96a);}})['then'](function(_0x2ec867){if(_0x2ec867){return _0x2ec867?{'count':_0x4a717a,'rows':_0x2ec867}:null;}})[_0x6de3('0x35')](respondWithResult(_0x2f8677,null))[_0x6de3('0x26')](handleError(_0x2f8677,null));};
\ No newline at end of file