Built motion from commit (unavailable).|2.5.27
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index 0384f62..c722035 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4c60=['request-promise','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','./faxAccount.socket','client','http','request','request\x20sent','error','code','FaxAccount,\x20%s,\x20%s','message','info','result','catch','sendStatus','status','json','count','offset','limit','set','Content-Range','reject','save','then','destroy','end','name','send','index','Pause','map','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','FaxAccount','includeAll','include','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','FaxAccounts','UserProfileSection','userProfileId','update','describe','addDisposition','Disposition','FaxAccountId','findAll','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','rows','removeAnswers','addInteraction','FaxInteraction','omit','getInteractions','findOne','CmContact','Contact','Owner','Tag','color','tag','addApplications','sequelize','transaction','FaxApplication','bulkCreate','findAndCountAll','priority','getApplications','from-voip-provider','localstationid','app','description','Fax\x20Extension','push','Answer','CDR(type)=inbound-fax','Set','ecm','faxdetect','headerinfo','maxrate','minrate','Wait','updateAccountApplications','tech','updatedAt','TrunkId','ListId','findById','getMessages','FaxMessage','$gte','split','format','List','Contacts','DESC','attachments','join','root','server/files/attachments','basename','CheckAfterSend','isNil','from','fax','defaults','out','filename','Contact\x20not\x20found','spread','ContactId','dataValues','Messages','SendFax','SendFaxRpc,\x20%s','addAgents','emit','removeAgents','isArray','userFaxAccount:remove','getAgents','User','html-pdf','eml-format','rimraf','zip-dir'];(function(_0x26efac,_0x21ab8a){var _0x8482e4=function(_0x14db32){while(--_0x14db32){_0x26efac['push'](_0x26efac['shift']());}};_0x8482e4(++_0x21ab8a);}(_0x4c60,0x166));var _0x04c6=function(_0x582618,_0x5617df){_0x582618=_0x582618-0x0;var _0x102f70=_0x4c60[_0x582618];return _0x102f70;};'use strict';var pdf=require(_0x04c6('0x0'));var emlformat=require(_0x04c6('0x1'));var rimraf=require(_0x04c6('0x2'));var zipdir=require(_0x04c6('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x04c6('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x04c6('0x5'));var util=require(_0x04c6('0x6'));var path=require(_0x04c6('0x7'));var sox=require(_0x04c6('0x8'));var csv=require('to-csv');var ejs=require(_0x04c6('0x9'));var fs=require('fs');var _=require(_0x04c6('0xa'));var squel=require(_0x04c6('0xb'));var crypto=require(_0x04c6('0xc'));var jsforce=require(_0x04c6('0xd'));var deskjs=require(_0x04c6('0xe'));var toCsv=require('to-csv');var querystring=require(_0x04c6('0xf'));var Papa=require(_0x04c6('0x10'));var Redis=require(_0x04c6('0x11'));var authService=require(_0x04c6('0x12'));var qs=require(_0x04c6('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x04c6('0x14'));var logger=require(_0x04c6('0x15'))('api');var utils=require(_0x04c6('0x16'));var config=require(_0x04c6('0x17'));var licenseUtil=require(_0x04c6('0x18'));var db=require(_0x04c6('0x19'))['db'];config[_0x04c6('0x1a')]=_['defaults'](config[_0x04c6('0x1a')],{'host':_0x04c6('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x04c6('0x1a')]));require(_0x04c6('0x1c'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0x04c6('0x1d')][_0x04c6('0x1e')]({'port':0x232c});var client9002=jayson[_0x04c6('0x1d')]['http']({'port':0x232a});function respondWithRpcPromise(_0x43c194,_0x3cac5c,_0xaa396f,_0x48b174){return new BPromise(function(_0x25bafd,_0x4e226c){var _0x37cf3c=_0x48b174||client;return _0x37cf3c[_0x04c6('0x1f')](_0x43c194,_0xaa396f)['then'](function(_0x2632c5){logger['info']('FaxAccount,\x20%s,\x20%s',_0x3cac5c,_0x04c6('0x20'));logger['debug']('FaxAccount,\x20%s,\x20%s,\x20%s',_0x3cac5c,_0x04c6('0x20'),JSON['stringify'](_0x2632c5));if(_0x2632c5[_0x04c6('0x21')]){if(_0x2632c5[_0x04c6('0x21')][_0x04c6('0x22')]===0x1f4){logger[_0x04c6('0x21')](_0x04c6('0x23'),_0x3cac5c,_0x2632c5[_0x04c6('0x21')]['message']);return _0x4e226c(_0x2632c5[_0x04c6('0x21')][_0x04c6('0x24')]);}logger['error'](_0x04c6('0x23'),_0x3cac5c,_0x2632c5[_0x04c6('0x21')][_0x04c6('0x24')]);return _0x25bafd(_0x2632c5['error'][_0x04c6('0x24')]);}else{logger[_0x04c6('0x25')]('FaxAccount,\x20%s,\x20%s',_0x3cac5c,_0x04c6('0x20'));_0x25bafd(_0x2632c5[_0x04c6('0x26')][_0x04c6('0x24')]);}})[_0x04c6('0x27')](function(_0x22a55f){logger[_0x04c6('0x21')](_0x04c6('0x23'),_0x3cac5c,_0x22a55f);_0x4e226c(_0x22a55f);});});}function respondWithStatusCode(_0x34db8a,_0x5461f5){_0x5461f5=_0x5461f5||0xcc;return function(_0x28bcee){if(_0x28bcee){return _0x34db8a[_0x04c6('0x28')](_0x5461f5);}return _0x34db8a[_0x04c6('0x29')](_0x5461f5)['end']();};}function respondWithResult(_0x58746d,_0x39634f){_0x39634f=_0x39634f||0xc8;return function(_0x4f4df0){if(_0x4f4df0){return _0x58746d[_0x04c6('0x29')](_0x39634f)[_0x04c6('0x2a')](_0x4f4df0);}};}function respondWithFilteredResult(_0x228c00,_0xbdad63){return function(_0x5d79b8){if(_0x5d79b8){var _0x1fc004=_0x5d79b8[_0x04c6('0x2b')],_0x4355dd=_0xbdad63[_0x04c6('0x2c')],_0x1e313c=_0xbdad63[_0x04c6('0x2c')]+_0xbdad63[_0x04c6('0x2d')],_0x227f8f;if(_0x1e313c>=_0x1fc004){_0x1e313c=_0x1fc004;_0x227f8f=0xc8;}else{_0x227f8f=0xce;}_0x228c00['status'](_0x227f8f);return _0x228c00[_0x04c6('0x2e')](_0x04c6('0x2f'),_0x4355dd+'-'+_0x1e313c+'/'+_0x1fc004)[_0x04c6('0x2a')](_0x5d79b8);}return null;};}function patchUpdates(_0x5ca112){return function(_0xe1351e){try{jsonpatch['apply'](_0xe1351e,_0x5ca112,!![]);}catch(_0x2b970e){return BPromise[_0x04c6('0x30')](_0x2b970e);}return _0xe1351e[_0x04c6('0x31')]();};}function saveUpdates(_0x28cb4b,_0x10e967){return function(_0x288d83){if(_0x288d83){return _0x288d83['update'](_0x28cb4b)[_0x04c6('0x32')](function(_0x27ad0c){return _0x27ad0c;});}return null;};}function removeEntity(_0x3262b5,_0xbd6b60){return function(_0x259cdd){if(_0x259cdd){return _0x259cdd[_0x04c6('0x33')]()[_0x04c6('0x32')](function(){var _0x5b8c65=_0x259cdd['get']({'plain':!![]});var _0xfe8d72='FaxAccounts';return db['UserProfileResource'][_0x04c6('0x33')]({'where':{'type':_0xfe8d72,'resourceId':_0x5b8c65['id']}})[_0x04c6('0x32')](function(){return _0x259cdd;});})[_0x04c6('0x32')](function(){_0x3262b5['status'](0xcc)[_0x04c6('0x34')]();});}};}function handleEntityNotFound(_0x2499e9,_0x49a795){return function(_0xbc83ac){if(!_0xbc83ac){_0x2499e9[_0x04c6('0x28')](0x194);}return _0xbc83ac;};}function handleError(_0x2fbe5c,_0x319277){_0x319277=_0x319277||0x1f4;return function(_0x259760){logger['error'](_0x259760['stack']);if(_0x259760[_0x04c6('0x35')]){delete _0x259760[_0x04c6('0x35')];}_0x2fbe5c[_0x04c6('0x29')](_0x319277)[_0x04c6('0x36')](_0x259760);};}exports[_0x04c6('0x37')]=function(_0x41b228,_0x14df20){var _0x2615f9={'include':[{'model':db[_0x04c6('0x38')],'as':'mandatoryDispositionPause'}]},_0x5cea82={},_0x2d50fe={'count':0x0,'rows':[]};var _0x4695e1=_[_0x04c6('0x39')](db['FaxAccount'][_0x04c6('0x3a')],function(_0x209f21){return{'name':_0x209f21['fieldName'],'type':_0x209f21[_0x04c6('0x3b')][_0x04c6('0x3c')]};});_0x5cea82[_0x04c6('0x3d')]=_[_0x04c6('0x39')](_0x4695e1,_0x04c6('0x35'));_0x5cea82[_0x04c6('0x3e')]=_[_0x04c6('0x3f')](_0x41b228[_0x04c6('0x3e')]);_0x5cea82[_0x04c6('0x40')]=_[_0x04c6('0x41')](_0x5cea82['model'],_0x5cea82['query']);_0x2615f9[_0x04c6('0x42')]=_[_0x04c6('0x41')](_0x5cea82[_0x04c6('0x3d')],qs[_0x04c6('0x43')](_0x41b228[_0x04c6('0x3e')]['fields']));_0x2615f9[_0x04c6('0x42')]=_0x2615f9[_0x04c6('0x42')][_0x04c6('0x44')]?_0x2615f9[_0x04c6('0x42')]:_0x5cea82[_0x04c6('0x3d')];if(!_0x41b228[_0x04c6('0x3e')][_0x04c6('0x45')](_0x04c6('0x46'))){_0x2615f9['limit']=qs['limit'](_0x41b228[_0x04c6('0x3e')][_0x04c6('0x2d')]);_0x2615f9[_0x04c6('0x2c')]=qs[_0x04c6('0x2c')](_0x41b228['query'][_0x04c6('0x2c')]);}_0x2615f9[_0x04c6('0x47')]=qs[_0x04c6('0x48')](_0x41b228[_0x04c6('0x3e')][_0x04c6('0x48')]);_0x2615f9[_0x04c6('0x49')]=qs[_0x04c6('0x40')](_[_0x04c6('0x4a')](_0x41b228[_0x04c6('0x3e')],_0x5cea82['filters']),_0x4695e1);if(_0x41b228[_0x04c6('0x3e')][_0x04c6('0x4b')]){_0x2615f9[_0x04c6('0x49')]=_[_0x04c6('0x4c')](_0x2615f9['where'],{'$or':_[_0x04c6('0x39')](_0x4695e1,function(_0x9acc89){if(_0x9acc89[_0x04c6('0x3b')]!==_0x04c6('0x4d')){var _0x4302d2={};_0x4302d2[_0x9acc89[_0x04c6('0x35')]]={'$like':'%'+_0x41b228[_0x04c6('0x3e')]['filter']+'%'};return _0x4302d2;}})});}_0x2615f9=_[_0x04c6('0x4c')]({},_0x2615f9,_0x41b228[_0x04c6('0x4e')]);var _0x4574e6={'where':_0x2615f9[_0x04c6('0x49')]};return db[_0x04c6('0x4f')][_0x04c6('0x2b')](_0x4574e6)['then'](function(_0x1f27f4){_0x2d50fe['count']=_0x1f27f4;if(_0x41b228['query'][_0x04c6('0x50')]){_0x2615f9[_0x04c6('0x51')]=[{'all':!![]}];}return db[_0x04c6('0x4f')]['findAll'](_0x2615f9);})[_0x04c6('0x32')](function(_0x45c0a7){_0x2d50fe['rows']=_0x45c0a7;return _0x2d50fe;})[_0x04c6('0x32')](respondWithFilteredResult(_0x14df20,_0x2615f9))[_0x04c6('0x27')](handleError(_0x14df20,null));};exports[_0x04c6('0x52')]=function(_0x193da1,_0x5207c8){var _0x5a4e44={'raw':![],'where':{'id':_0x193da1[_0x04c6('0x53')]['id']},'include':[{'model':db[_0x04c6('0x38')],'as':'mandatoryDispositionPause'}]},_0x2c4157={};_0x2c4157['model']=_[_0x04c6('0x3f')](db['FaxAccount'][_0x04c6('0x3a')]);_0x2c4157[_0x04c6('0x3e')]=_[_0x04c6('0x3f')](_0x193da1['query']);_0x2c4157[_0x04c6('0x40')]=_[_0x04c6('0x41')](_0x2c4157[_0x04c6('0x3d')],_0x2c4157[_0x04c6('0x3e')]);_0x5a4e44[_0x04c6('0x42')]=_[_0x04c6('0x41')](_0x2c4157[_0x04c6('0x3d')],qs['fields'](_0x193da1['query'][_0x04c6('0x43')]));_0x5a4e44[_0x04c6('0x42')]=_0x5a4e44['attributes']['length']?_0x5a4e44[_0x04c6('0x42')]:_0x2c4157[_0x04c6('0x3d')];if(_0x193da1['query']['includeAll']){_0x5a4e44[_0x04c6('0x51')]=[{'all':!![]}];}_0x5a4e44=_[_0x04c6('0x4c')]({},_0x5a4e44,_0x193da1[_0x04c6('0x4e')]);return db[_0x04c6('0x4f')][_0x04c6('0x54')](_0x5a4e44)['then'](handleEntityNotFound(_0x5207c8,null))[_0x04c6('0x32')](respondWithResult(_0x5207c8,null))[_0x04c6('0x27')](handleError(_0x5207c8,null));};exports[_0x04c6('0x55')]=function(_0x1d0c96,_0x5b7b7b){return db[_0x04c6('0x4f')][_0x04c6('0x55')](_0x1d0c96[_0x04c6('0x56')],{})['then'](function(_0x2836a2){var _0x5f38f0=_0x1d0c96[_0x04c6('0x57')]['get']({'plain':!![]});if(!_0x5f38f0)throw new Error(_0x04c6('0x58'));if(_0x5f38f0[_0x04c6('0x59')]==='user'){var _0x32628c=_0x2836a2[_0x04c6('0x5a')]({'plain':!![]});var _0x188bb0=_0x04c6('0x5b');return db[_0x04c6('0x5c')][_0x04c6('0x54')]({'where':{'name':_0x188bb0,'userProfileId':_0x5f38f0[_0x04c6('0x5d')]},'raw':!![]})[_0x04c6('0x32')](function(_0x523ba4){if(_0x523ba4&&_0x523ba4['autoAssociation']===0x0){return db['UserProfileResource'][_0x04c6('0x55')]({'name':_0x32628c[_0x04c6('0x35')],'resourceId':_0x32628c['id'],'type':_0x523ba4['name'],'sectionId':_0x523ba4['id']},{})[_0x04c6('0x32')](function(){return _0x2836a2;});}else{return _0x2836a2;}})['catch'](function(_0x3c3e30){logger[_0x04c6('0x21')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3c3e30);throw _0x3c3e30;});}return _0x2836a2;})['then'](respondWithResult(_0x5b7b7b,0xc9))[_0x04c6('0x27')](handleError(_0x5b7b7b,null));};exports[_0x04c6('0x5e')]=function(_0x390b4a,_0x2153ee){if(_0x390b4a[_0x04c6('0x56')]['id']){delete _0x390b4a['body']['id'];}return db[_0x04c6('0x4f')][_0x04c6('0x54')]({'where':{'id':_0x390b4a[_0x04c6('0x53')]['id']},'include':[{'model':db[_0x04c6('0x38')],'as':'mandatoryDispositionPause'}]})[_0x04c6('0x32')](handleEntityNotFound(_0x2153ee,null))['then'](saveUpdates(_0x390b4a[_0x04c6('0x56')],null))[_0x04c6('0x32')](respondWithResult(_0x2153ee,null))[_0x04c6('0x27')](handleError(_0x2153ee,null));};exports['destroy']=function(_0x40d39c,_0x106fde){return db['FaxAccount'][_0x04c6('0x54')]({'where':{'id':_0x40d39c[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x106fde,null))['then'](removeEntity(_0x106fde,null))[_0x04c6('0x27')](handleError(_0x106fde,null));};exports[_0x04c6('0x5f')]=function(_0x3c7833,_0x449948){return db['FaxAccount'][_0x04c6('0x5f')]()[_0x04c6('0x32')](respondWithResult(_0x449948,null))[_0x04c6('0x27')](handleError(_0x449948,null));};exports[_0x04c6('0x60')]=function(_0x257542,_0x28e0aa,_0x5e2a46){if(_0x257542['body']['id']){delete _0x257542[_0x04c6('0x56')]['id'];}return db['FaxAccount'][_0x04c6('0x54')]({'where':{'id':_0x257542[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x28e0aa,null))[_0x04c6('0x32')](function(_0x3575bc){if(_0x3575bc){_0x257542[_0x04c6('0x56')]['FaxAccountId']=_0x3575bc['id'];return db[_0x04c6('0x61')][_0x04c6('0x55')](_0x257542[_0x04c6('0x56')]);}})[_0x04c6('0x32')](respondWithResult(_0x28e0aa,null))['catch'](handleError(_0x28e0aa,null));};exports['getDispositions']=function(_0x3ce2f9,_0x55e502,_0x2ccd2d){var _0x2645be={'raw':![],'where':{}};var _0x165b9a={};var _0x1be4eb={'count':0x0,'rows':[]};return db[_0x04c6('0x4f')]['findOne']({'where':{'id':_0x3ce2f9[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x55e502,null))[_0x04c6('0x32')](function(_0x1d880c){if(_0x1d880c){_0x165b9a[_0x04c6('0x3d')]=_['keys'](db[_0x04c6('0x61')][_0x04c6('0x3a')]);_0x165b9a[_0x04c6('0x3e')]=_[_0x04c6('0x3f')](_0x3ce2f9[_0x04c6('0x3e')]);_0x165b9a[_0x04c6('0x40')]=_[_0x04c6('0x41')](_0x165b9a[_0x04c6('0x3d')],_0x165b9a[_0x04c6('0x3e')]);_0x2645be[_0x04c6('0x42')]=_[_0x04c6('0x41')](_0x165b9a[_0x04c6('0x3d')],qs[_0x04c6('0x43')](_0x3ce2f9[_0x04c6('0x3e')][_0x04c6('0x43')]));_0x2645be[_0x04c6('0x42')]=_0x2645be[_0x04c6('0x42')]['length']?_0x2645be[_0x04c6('0x42')]:_0x165b9a[_0x04c6('0x3d')];if(!_0x3ce2f9[_0x04c6('0x3e')][_0x04c6('0x45')](_0x04c6('0x46'))){_0x2645be['limit']=qs[_0x04c6('0x2d')](_0x3ce2f9['query'][_0x04c6('0x2d')]);_0x2645be[_0x04c6('0x2c')]=qs[_0x04c6('0x2c')](_0x3ce2f9['query'][_0x04c6('0x2c')]);}_0x2645be[_0x04c6('0x47')]=qs[_0x04c6('0x48')](_0x3ce2f9['query']['sort']);_0x2645be[_0x04c6('0x49')]=qs[_0x04c6('0x40')](_[_0x04c6('0x4a')](_0x3ce2f9[_0x04c6('0x3e')],_0x165b9a[_0x04c6('0x40')]));_0x2645be['where'][_0x04c6('0x62')]=_0x1d880c['id'];if(_0x3ce2f9[_0x04c6('0x3e')][_0x04c6('0x4b')]){_0x2645be['where']=_[_0x04c6('0x4c')](_0x2645be['where'],{'$or':_[_0x04c6('0x39')](_0x2645be[_0x04c6('0x42')],function(_0x48ee7e){var _0x11ff35={};_0x11ff35[_0x48ee7e]={'$like':'%'+_0x3ce2f9[_0x04c6('0x3e')][_0x04c6('0x4b')]+'%'};return _0x11ff35;})});}_0x2645be=_[_0x04c6('0x4c')]({},_0x2645be,_0x3ce2f9[_0x04c6('0x4e')]);return db[_0x04c6('0x61')][_0x04c6('0x2b')]({'where':_0x2645be[_0x04c6('0x49')]})[_0x04c6('0x32')](function(_0x1788e0){_0x1be4eb['count']=_0x1788e0;if(_0x3ce2f9[_0x04c6('0x3e')]['includeAll']){_0x2645be['include']=[{'all':!![]}];}return db[_0x04c6('0x61')][_0x04c6('0x63')](_0x2645be);})[_0x04c6('0x32')](function(_0x124e5e){_0x1be4eb['rows']=_0x124e5e;return _0x1be4eb;});}})[_0x04c6('0x32')](respondWithFilteredResult(_0x55e502,_0x2645be))[_0x04c6('0x27')](handleError(_0x55e502,null));};exports['removeDispositions']=function(_0x363b6e,_0x5d61ca,_0x35b3f3){return db[_0x04c6('0x4f')][_0x04c6('0x54')]({'where':{'id':_0x363b6e[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x5d61ca,null))[_0x04c6('0x32')](function(_0x29b6bf){if(_0x29b6bf){return _0x29b6bf[_0x04c6('0x64')](_0x363b6e[_0x04c6('0x3e')][_0x04c6('0x65')]);}})[_0x04c6('0x32')](respondWithStatusCode(_0x5d61ca,null))[_0x04c6('0x27')](handleError(_0x5d61ca,null));};exports[_0x04c6('0x66')]=function(_0x419f5a,_0xd455e8,_0x436acb){if(_0x419f5a[_0x04c6('0x56')]['id']){delete _0x419f5a[_0x04c6('0x56')]['id'];}return db[_0x04c6('0x4f')][_0x04c6('0x54')]({'where':{'id':_0x419f5a[_0x04c6('0x53')]['id']}})['then'](handleEntityNotFound(_0xd455e8,null))[_0x04c6('0x32')](function(_0x398272){if(_0x398272){_0x419f5a[_0x04c6('0x56')]['FaxAccountId']=_0x398272['id'];return db[_0x04c6('0x67')][_0x04c6('0x55')](_0x419f5a[_0x04c6('0x56')]);}})['then'](respondWithResult(_0xd455e8,null))[_0x04c6('0x27')](handleError(_0xd455e8,null));};exports[_0x04c6('0x68')]=function(_0x48f517,_0x50ccfb,_0x35c76d){var _0x4de128={'raw':![],'where':{}};var _0x439f4f={};var _0x180d3e={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x48f517[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x50ccfb,null))[_0x04c6('0x32')](function(_0x30f325){if(_0x30f325){_0x439f4f['model']=_[_0x04c6('0x3f')](db[_0x04c6('0x67')][_0x04c6('0x3a')]);_0x439f4f['query']=_[_0x04c6('0x3f')](_0x48f517['query']);_0x439f4f[_0x04c6('0x40')]=_['intersection'](_0x439f4f[_0x04c6('0x3d')],_0x439f4f[_0x04c6('0x3e')]);_0x4de128[_0x04c6('0x42')]=_[_0x04c6('0x41')](_0x439f4f[_0x04c6('0x3d')],qs[_0x04c6('0x43')](_0x48f517['query'][_0x04c6('0x43')]));_0x4de128['attributes']=_0x4de128[_0x04c6('0x42')][_0x04c6('0x44')]?_0x4de128['attributes']:_0x439f4f[_0x04c6('0x3d')];if(!_0x48f517[_0x04c6('0x3e')]['hasOwnProperty'](_0x04c6('0x46'))){_0x4de128[_0x04c6('0x2d')]=qs['limit'](_0x48f517[_0x04c6('0x3e')][_0x04c6('0x2d')]);_0x4de128[_0x04c6('0x2c')]=qs[_0x04c6('0x2c')](_0x48f517[_0x04c6('0x3e')][_0x04c6('0x2c')]);}_0x4de128[_0x04c6('0x47')]=qs[_0x04c6('0x48')](_0x48f517[_0x04c6('0x3e')]['sort']);_0x4de128['where']=qs[_0x04c6('0x40')](_[_0x04c6('0x4a')](_0x48f517['query'],_0x439f4f[_0x04c6('0x40')]));_0x4de128[_0x04c6('0x49')][_0x04c6('0x62')]=_0x30f325['id'];if(_0x48f517['query'][_0x04c6('0x4b')]){_0x4de128[_0x04c6('0x49')]=_[_0x04c6('0x4c')](_0x4de128[_0x04c6('0x49')],{'$or':_[_0x04c6('0x39')](_0x4de128['attributes'],function(_0x4530c3){var _0x2d7a36={};_0x2d7a36[_0x4530c3]={'$like':'%'+_0x48f517[_0x04c6('0x3e')]['filter']+'%'};return _0x2d7a36;})});}_0x4de128=_[_0x04c6('0x4c')]({},_0x4de128,_0x48f517[_0x04c6('0x4e')]);return db[_0x04c6('0x67')][_0x04c6('0x2b')]({'where':_0x4de128['where']})[_0x04c6('0x32')](function(_0x1226c1){_0x180d3e['count']=_0x1226c1;if(_0x48f517['query'][_0x04c6('0x50')]){_0x4de128[_0x04c6('0x51')]=[{'all':!![]}];}return db['CannedAnswer'][_0x04c6('0x63')](_0x4de128);})[_0x04c6('0x32')](function(_0x518fde){_0x180d3e[_0x04c6('0x69')]=_0x518fde;return _0x180d3e;});}})[_0x04c6('0x32')](respondWithFilteredResult(_0x50ccfb,_0x4de128))[_0x04c6('0x27')](handleError(_0x50ccfb,null));};exports[_0x04c6('0x6a')]=function(_0x1c248c,_0x155370,_0x462b0d){return db[_0x04c6('0x4f')][_0x04c6('0x54')]({'where':{'id':_0x1c248c[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x155370,null))[_0x04c6('0x32')](function(_0x526af0){if(_0x526af0){return _0x526af0[_0x04c6('0x6a')](_0x1c248c[_0x04c6('0x3e')][_0x04c6('0x65')]);}})[_0x04c6('0x32')](respondWithStatusCode(_0x155370,null))['catch'](handleError(_0x155370,null));};exports[_0x04c6('0x6b')]=function(_0x2df155,_0x1bf5db,_0x53febd){return db[_0x04c6('0x6c')][_0x04c6('0x54')]({'where':{'id':_0x2df155[_0x04c6('0x53')]['id']}})['then'](handleEntityNotFound(_0x1bf5db,null))['then'](function(_0x343a70){if(_0x343a70){return _0x343a70[_0x04c6('0x6b')](_0x2df155[_0x04c6('0x56')][_0x04c6('0x65')],_[_0x04c6('0x6d')](_0x2df155['body'],['ids','id'])||{});}})[_0x04c6('0x32')](respondWithResult(_0x1bf5db,null))[_0x04c6('0x27')](handleError(_0x1bf5db,null));};exports[_0x04c6('0x6e')]=function(_0x104bfd,_0x397453,_0x165601){var _0x387060={'raw':![],'where':{}};var _0x2843b2={};var _0x3df65a={'count':0x0,'rows':[]};return db[_0x04c6('0x4f')][_0x04c6('0x6f')]({'where':{'id':_0x104bfd[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x397453,null))[_0x04c6('0x32')](function(_0x57266f){if(_0x57266f){_0x2843b2[_0x04c6('0x3d')]=_[_0x04c6('0x3f')](db[_0x04c6('0x6c')][_0x04c6('0x3a')]);_0x2843b2[_0x04c6('0x3e')]=_[_0x04c6('0x3f')](_0x104bfd[_0x04c6('0x3e')]);_0x2843b2[_0x04c6('0x40')]=_[_0x04c6('0x41')](_0x2843b2[_0x04c6('0x3d')],_0x2843b2['query']);_0x387060[_0x04c6('0x42')]=_[_0x04c6('0x41')](_0x2843b2['model'],qs[_0x04c6('0x43')](_0x104bfd['query'][_0x04c6('0x43')]));_0x387060[_0x04c6('0x42')]=_0x387060[_0x04c6('0x42')][_0x04c6('0x44')]?_0x387060[_0x04c6('0x42')]:_0x2843b2[_0x04c6('0x3d')];if(!_0x104bfd[_0x04c6('0x3e')][_0x04c6('0x45')](_0x04c6('0x46'))){_0x387060['limit']=qs['limit'](_0x104bfd[_0x04c6('0x3e')][_0x04c6('0x2d')]);_0x387060[_0x04c6('0x2c')]=qs[_0x04c6('0x2c')](_0x104bfd[_0x04c6('0x3e')][_0x04c6('0x2c')]);}_0x387060[_0x04c6('0x47')]=qs[_0x04c6('0x48')](_0x104bfd['query']['sort']);_0x387060['where']=qs[_0x04c6('0x40')](_[_0x04c6('0x4a')](_0x104bfd[_0x04c6('0x3e')],_0x2843b2[_0x04c6('0x40')]));_0x387060[_0x04c6('0x49')][_0x04c6('0x62')]=_0x57266f['id'];if(_0x104bfd[_0x04c6('0x3e')][_0x04c6('0x4b')]){_0x387060[_0x04c6('0x49')]=_[_0x04c6('0x4c')](_0x387060[_0x04c6('0x49')],{'$or':_[_0x04c6('0x39')](_0x387060[_0x04c6('0x42')],function(_0x259f38){var _0x5544e0={};_0x5544e0[_0x259f38]={'$like':'%'+_0x104bfd[_0x04c6('0x3e')][_0x04c6('0x4b')]+'%'};return _0x5544e0;})});}_0x387060=_[_0x04c6('0x4c')]({},_0x387060,_0x104bfd['options']);return db['FaxInteraction'][_0x04c6('0x2b')]({'where':_0x387060[_0x04c6('0x49')]})[_0x04c6('0x32')](function(_0x390654){_0x3df65a[_0x04c6('0x2b')]=_0x390654;if(_0x104bfd[_0x04c6('0x3e')][_0x04c6('0x50')]){_0x387060[_0x04c6('0x51')]=[{'model':db[_0x04c6('0x70')],'as':_0x04c6('0x71'),'required':![]},{'model':db['User'],'as':_0x04c6('0x72'),'attributes':[_0x04c6('0x35'),'fullname','internal'],'required':![]},{'model':db[_0x04c6('0x73')],'as':'Tags','attributes':['id',_0x04c6('0x35'),_0x04c6('0x74')],'where':_0x104bfd[_0x04c6('0x3e')][_0x04c6('0x75')]?{'id':_0x104bfd['query']['tag']}:undefined,'required':_0x104bfd['query']['tag']?!![]:![]}];}return db[_0x04c6('0x6c')][_0x04c6('0x63')](_0x387060);})['then'](function(_0x5d7e7d){_0x3df65a[_0x04c6('0x69')]=_0x5d7e7d;return _0x3df65a;});}})[_0x04c6('0x32')](respondWithFilteredResult(_0x397453,_0x387060))[_0x04c6('0x27')](handleError(_0x397453,null));};exports[_0x04c6('0x76')]=function(_0x1ac2be,_0x43587d,_0x2458f4){return db[_0x04c6('0x4f')]['findOne']({'where':{'id':_0x1ac2be[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x43587d,null))[_0x04c6('0x32')](function(_0x2f989f){if(_0x2f989f){return db[_0x04c6('0x77')][_0x04c6('0x78')](function(_0x36e151){return db[_0x04c6('0x79')][_0x04c6('0x33')]({'where':{'FaxAccountId':_0x1ac2be[_0x04c6('0x53')]['id']},'transaction':_0x36e151})[_0x04c6('0x32')](function(_0x1df360){var _0x8b6784=_[_0x04c6('0x39')](_0x1ac2be[_0x04c6('0x56')],function(_0x262fda){_0x262fda[_0x04c6('0x62')]=_0x1ac2be[_0x04c6('0x53')]['id'];return _0x262fda;});return db['FaxApplication'][_0x04c6('0x7a')](_0x8b6784,{'transaction':_0x36e151});});})[_0x04c6('0x32')](function(){return db[_0x04c6('0x79')][_0x04c6('0x7b')]({'where':{'FaxAccountId':_0x1ac2be[_0x04c6('0x53')]['id']},'order':_0x04c6('0x7c')});});}})[_0x04c6('0x32')](respondWithResult(_0x43587d,null))[_0x04c6('0x27')](handleError(_0x43587d,null));};exports[_0x04c6('0x7d')]=function(_0x189218,_0x306ae1,_0x3cf9f9){var _0x589c33={};var _0x181cba={};var _0x58f647;var _0x5f05c8;return db[_0x04c6('0x4f')][_0x04c6('0x6f')]({'where':{'id':_0x189218[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x306ae1,null))[_0x04c6('0x32')](function(_0x4e6af7){if(_0x4e6af7){_0x58f647=_0x4e6af7;_0x181cba[_0x04c6('0x3d')]=_['keys'](db[_0x04c6('0x79')][_0x04c6('0x3a')]);_0x181cba['query']=_['keys'](_0x189218[_0x04c6('0x3e')]);_0x181cba[_0x04c6('0x40')]=_[_0x04c6('0x41')](_0x181cba[_0x04c6('0x3d')],_0x181cba[_0x04c6('0x3e')]);_0x589c33['attributes']=_[_0x04c6('0x41')](_0x181cba['model'],qs[_0x04c6('0x43')](_0x189218['query'][_0x04c6('0x43')]));_0x589c33[_0x04c6('0x42')]=_0x589c33['attributes'][_0x04c6('0x44')]?_0x589c33['attributes']:_0x181cba[_0x04c6('0x3d')];_0x589c33[_0x04c6('0x47')]=qs['sort'](_0x189218[_0x04c6('0x3e')][_0x04c6('0x48')]);_0x589c33['where']=qs[_0x04c6('0x40')](_[_0x04c6('0x4a')](_0x189218[_0x04c6('0x3e')],_0x181cba[_0x04c6('0x40')]));if(_0x189218[_0x04c6('0x3e')]['filter']){_0x589c33[_0x04c6('0x49')]=_[_0x04c6('0x4c')](_0x589c33[_0x04c6('0x49')],{'$or':_[_0x04c6('0x39')](_0x589c33[_0x04c6('0x42')],function(_0x383092){var _0xd7cab2={};_0xd7cab2[_0x383092]={'$like':'%'+_0x189218[_0x04c6('0x3e')][_0x04c6('0x4b')]+'%'};return _0xd7cab2;})});}_0x589c33=_[_0x04c6('0x4c')]({},_0x589c33,_0x189218['options']);return _0x58f647[_0x04c6('0x7d')](_0x589c33);}})['then'](function(_0xfc595f){if(_0xfc595f){_0x5f05c8=_0xfc595f[_0x04c6('0x44')];if(!_0x189218['query']['hasOwnProperty'](_0x04c6('0x46'))){_0x589c33['limit']=qs[_0x04c6('0x2d')](_0x189218[_0x04c6('0x3e')][_0x04c6('0x2d')]);_0x589c33[_0x04c6('0x2c')]=qs[_0x04c6('0x2c')](_0x189218[_0x04c6('0x3e')][_0x04c6('0x2c')]);}return _0x58f647[_0x04c6('0x7d')](_0x589c33);}})[_0x04c6('0x32')](function(_0xcd2790){if(_0xcd2790){return _0xcd2790?{'count':_0x5f05c8,'rows':_0xcd2790}:null;}})[_0x04c6('0x32')](respondWithResult(_0x306ae1,null))[_0x04c6('0x27')](handleError(_0x306ae1,null));};function Extension(_0x166cd1,_0x2c9b5a,_0xa098dd,_0x1bdb6){this['context']=_0x04c6('0x7e');this['exten']=_0x166cd1[_0x04c6('0x7f')];this[_0x04c6('0x80')]=_0x1bdb6;this[_0x04c6('0x3b')]='system';this[_0x04c6('0x81')]=_0x04c6('0x82');this['FaxAccountId']=_0x166cd1['id'];this[_0x04c6('0x7c')]=_0x2c9b5a;this['appdata']=_0xa098dd;}function createExtensionsReciveFax(_0x3097f2){var _0x376252=0x1;var _0x1bf374=[];_0x1bf374[_0x04c6('0x83')](new Extension(_0x3097f2,_0x376252,'',_0x04c6('0x84')));_0x376252+=0x1;_0x1bf374[_0x04c6('0x83')](new Extension(_0x3097f2,_0x376252,_0x04c6('0x85'),_0x04c6('0x86')));_0x376252+=0x1;for(var _0x7629a4 in _0x3097f2){if(_0x3097f2['hasOwnProperty'](_0x7629a4)&&(_0x7629a4===_0x04c6('0x87')||_0x7629a4===_0x04c6('0x7f')||_0x7629a4==='gateway'||_0x7629a4===_0x04c6('0x88')||_0x7629a4===_0x04c6('0x89')||_0x7629a4===_0x04c6('0x8a')||_0x7629a4===_0x04c6('0x8b')||_0x7629a4==='modem'||_0x7629a4==='t38timeout')){_0x1bf374[_0x04c6('0x83')](new Extension(_0x3097f2,_0x376252,'FAXOPT('+_0x7629a4+')='+_0x3097f2[_0x7629a4],'Set'));_0x376252+=0x1;}}_0x1bf374[_0x04c6('0x83')](new Extension(_0x3097f2,_0x376252,'6',_0x04c6('0x8c')));_0x376252+=0x1;_0x1bf374[_0x04c6('0x83')](new Extension(_0x3097f2,_0x376252,'/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'));_0x376252=0x0;return _0x1bf374;}exports['addAccountApplications']=function(_0x1c663d,_0x6fc176,_0x44345e){var _0x7efabc;return db[_0x04c6('0x77')][_0x04c6('0x78')](function(_0xa8110c){return db[_0x04c6('0x4f')][_0x04c6('0x55')](_0x1c663d['body'],{'transaction':_0xa8110c})[_0x04c6('0x32')](function(_0x5c9186){_0x7efabc=_0x5c9186[_0x04c6('0x5a')]({'plain':!![]});return db['VoiceExtension'][_0x04c6('0x7a')](createExtensionsReciveFax(_0x7efabc),{'transaction':_0xa8110c});});})[_0x04c6('0x32')](function(){return _0x7efabc;})[_0x04c6('0x32')](respondWithResult(_0x6fc176,null))[_0x04c6('0x27')](handleError(_0x6fc176,null));};exports[_0x04c6('0x8d')]=function(_0xd43dd4,_0x3269df,_0x1bebc5){var _0x11d7fd;return db[_0x04c6('0x77')][_0x04c6('0x78')](function(_0x43b416){return db[_0x04c6('0x4f')][_0x04c6('0x5e')](_0xd43dd4[_0x04c6('0x56')],{'where':{'id':_0xd43dd4[_0x04c6('0x56')]['id']},'transaction':_0x43b416})[_0x04c6('0x32')](function(_0x3e665b){return db['VoiceExtension'][_0x04c6('0x33')]({'where':{'FaxAccountId':_0xd43dd4[_0x04c6('0x56')]['id']},'transaction':_0x43b416})['then'](function(_0x143e0f){return db['VoiceExtension']['bulkCreate'](createExtensionsReciveFax(_['omit'](_0xd43dd4['body'],[_0x04c6('0x8e'),_0x04c6('0x3c'),'createdAt',_0x04c6('0x8f'),_0x04c6('0x90'),_0x04c6('0x91')])),{'transaction':_0x43b416});});});})[_0x04c6('0x32')](function(){return db['FaxAccount'][_0x04c6('0x92')](_0xd43dd4[_0x04c6('0x56')]['id']);})[_0x04c6('0x32')](respondWithResult(_0x3269df,null))['catch'](handleError(_0x3269df,null));};exports[_0x04c6('0x93')]=function(_0x478d7b,_0x1d418a,_0x34409b){var _0x2d6644={'raw':!![],'where':{}};var _0x5475c6={};var _0x10e0bc={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x478d7b[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x1d418a,null))[_0x04c6('0x32')](function(_0x1ab5c9){if(_0x1ab5c9){_0x5475c6[_0x04c6('0x3d')]=_[_0x04c6('0x3f')](db[_0x04c6('0x94')][_0x04c6('0x3a')]);_0x5475c6['query']=_['keys'](_0x478d7b[_0x04c6('0x3e')]);_0x5475c6[_0x04c6('0x40')]=_[_0x04c6('0x41')](_0x5475c6[_0x04c6('0x3d')],_0x5475c6[_0x04c6('0x3e')]);_0x2d6644[_0x04c6('0x42')]=_['intersection'](_0x5475c6['model'],qs['fields'](_0x478d7b[_0x04c6('0x3e')][_0x04c6('0x43')]));_0x2d6644[_0x04c6('0x42')]=_0x2d6644[_0x04c6('0x42')][_0x04c6('0x44')]?_0x2d6644[_0x04c6('0x42')]:_0x5475c6[_0x04c6('0x3d')];if(!_0x478d7b['query'][_0x04c6('0x45')](_0x04c6('0x46'))){_0x2d6644[_0x04c6('0x2d')]=qs['limit'](_0x478d7b[_0x04c6('0x3e')][_0x04c6('0x2d')]);_0x2d6644[_0x04c6('0x2c')]=qs[_0x04c6('0x2c')](_0x478d7b[_0x04c6('0x3e')][_0x04c6('0x2c')]);}_0x2d6644[_0x04c6('0x47')]=qs['sort'](_0x478d7b[_0x04c6('0x3e')][_0x04c6('0x48')]);_0x2d6644[_0x04c6('0x49')]=qs['filters'](_[_0x04c6('0x4a')](_0x478d7b[_0x04c6('0x3e')],_0x5475c6['filters']));_0x2d6644[_0x04c6('0x49')]['FaxAccountId']=_0x1ab5c9['id'];if(_0x478d7b[_0x04c6('0x3e')][_0x04c6('0x4b')]){_0x2d6644[_0x04c6('0x49')]=_['merge'](_0x2d6644[_0x04c6('0x49')],{'$or':_[_0x04c6('0x39')](_0x2d6644['attributes'],function(_0x4d6472){var _0x53e80c={};_0x53e80c[_0x4d6472]={'$like':'%'+_0x478d7b[_0x04c6('0x3e')]['filter']+'%'};return _0x53e80c;})});}if(_0x478d7b['query'][_0x04c6('0x95')]){var _0x5c0507=_0x478d7b[_0x04c6('0x3e')][_0x04c6('0x95')][_0x04c6('0x96')](',');var _0x30c3df={};_0x30c3df[_0x5c0507[0x0]]={'$gte':moment(_0x5c0507[0x1])[_0x04c6('0x97')]('YYYY-MM-DD\x20HH:mm:ss')};_0x2d6644[_0x04c6('0x49')]=_[_0x04c6('0x4c')](_0x2d6644[_0x04c6('0x49')],_0x30c3df);}_0x2d6644=_['merge']({},_0x2d6644,_0x478d7b[_0x04c6('0x4e')]);return db[_0x04c6('0x94')]['count']({'where':_0x2d6644['where']})['then'](function(_0x44d2ba){_0x10e0bc[_0x04c6('0x2b')]=_0x44d2ba;if(_0x478d7b[_0x04c6('0x3e')][_0x04c6('0x50')]){_0x2d6644['include']=[{'all':!![]}];}return db[_0x04c6('0x94')][_0x04c6('0x63')](_0x2d6644);})['then'](function(_0x488ed1){_0x10e0bc[_0x04c6('0x69')]=_0x488ed1;return _0x10e0bc;});}})[_0x04c6('0x32')](respondWithFilteredResult(_0x1d418a,_0x2d6644))[_0x04c6('0x27')](handleError(_0x1d418a,null));};exports[_0x04c6('0x36')]=function(_0x1fdda1,_0x43d4b1,_0x5a77ab){var _0x3800b2,_0x25d16c={},_0x54326f;if(_0x1fdda1[_0x04c6('0x56')]['to']){_0x54326f=_0x1fdda1[_0x04c6('0x56')]['to'][0x0];}return db['FaxAccount'][_0x04c6('0x54')]({'where':{'id':_0x1fdda1[_0x04c6('0x53')]['id']},'include':[{'model':db['CmList'],'as':_0x04c6('0x98'),'include':[{'model':db[_0x04c6('0x70')],'as':_0x04c6('0x99'),'where':{'fax':_0x54326f},'limit':0x1,'order':[[_0x04c6('0x8f'),_0x04c6('0x9a')]]}]}]})['then'](handleEntityNotFound(_0x43d4b1,null))[_0x04c6('0x32')](function(_0x21c8d4){_0x3800b2=_0x21c8d4;if(_0x1fdda1['body']['attachments']&&_0x1fdda1[_0x04c6('0x56')]['attachments'][_0x04c6('0x44')]){for(var _0x332dd6=0x0;_0x332dd6<_0x1fdda1[_0x04c6('0x56')]['attachments'][_0x04c6('0x44')];_0x332dd6+=0x1){_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][_0x332dd6]={'filename':_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][_0x332dd6][_0x04c6('0x35')],'id':_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][_0x332dd6]['id'],'path':path[_0x04c6('0x9c')](config[_0x04c6('0x9d')],_0x04c6('0x9e'),_0x1fdda1['body'][_0x04c6('0x9b')][_0x332dd6][_0x04c6('0x9f')])};}}return respondWithRpcPromise(_0x04c6('0xa0'),_0x04c6('0xa0'),{'FaxAccountId':_[_0x04c6('0xa1')](_0x1fdda1[_0x04c6('0x53')]['id'])?undefined:_0x1fdda1[_0x04c6('0x53')]['id'],'path':_[_0x04c6('0xa1')](_0x1fdda1['body'][_0x04c6('0x9b')][0x0][_0x04c6('0x7')])?undefined:_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][0x0][_0x04c6('0x7')],'fax':_['isNil'](_0x1fdda1[_0x04c6('0x56')]['to'][0x0])?undefined:_0x1fdda1[_0x04c6('0x56')]['to'][0x0]},client9002);})[_0x04c6('0x32')](function(){if(_0x3800b2){if(_[_0x04c6('0xa1')](_0x1fdda1[_0x04c6('0x56')][_0x04c6('0xa2')])){_0x1fdda1[_0x04c6('0x56')][_0x04c6('0xa2')]=util[_0x04c6('0x97')]('\x22%s\x22\x20<%s>',_0x3800b2[_0x04c6('0x35')],_0x3800b2[_0x04c6('0xa3')]);}if(_0x3800b2['List']){if(_0x3800b2['List'][_0x04c6('0x99')][_0x04c6('0x44')]){return _0x3800b2[_0x04c6('0x98')][_0x04c6('0x99')][0x0];}else{return db['CmContact'][_0x04c6('0x55')](_[_0x04c6('0xa4')](_0x1fdda1[_0x04c6('0x56')],{'firstName':_0x1fdda1[_0x04c6('0x56')]['to'][0x0],'phone':_0x1fdda1[_0x04c6('0x56')]['to'][0x0],'fax':_0x1fdda1[_0x04c6('0x56')]['to'][0x0],'ListId':_0x3800b2[_0x04c6('0x91')]}));}}else{throw new Error('List\x20not\x20found');}}else{throw new Error('Send\x20Fax\x20failed');}})[_0x04c6('0x32')](function(_0xa7259f){if(_0xa7259f){return db[_0x04c6('0x6c')][_0x04c6('0x54')]({'where':{'ContactId':_0xa7259f['id'],'closed':![],'FaxAccountId':_0x3800b2['id']}})['then'](function(_0x94496f){if(_0x94496f){return[_0x94496f,![]];}return db[_0x04c6('0x6c')][_0x04c6('0x55')]({'UserId':_0x1fdda1[_0x04c6('0x57')]['id'],'ContactId':_0xa7259f['id'],'FaxAccountId':_0x3800b2['id'],'fax':_0x1fdda1['body']['to'][0x0],'firstMsgDirection':_0x04c6('0xa5'),'Messages':[_['merge'](_0x1fdda1[_0x04c6('0x56')],{'read':![],'body':_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][0x0][_0x04c6('0xa6')],'FaxAccountId':_0x3800b2['id'],'UserId':_0x1fdda1[_0x04c6('0x57')]['id'],'ContactId':_0xa7259f['id'],'AttachmentId':_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][0x0]['id']})]},{'include':[{'model':db[_0x04c6('0x94')],'as':'Messages'}]})[_0x04c6('0x32')](function(_0xf6026d){return[_0xf6026d,!![]];});});}else{throw new Error(_0x04c6('0xa7'));}})[_0x04c6('0xa8')](function(_0x7eff69,_0x3e3743){if(_0x3e3743){return _0x7eff69;}return db[_0x04c6('0x94')][_0x04c6('0x55')]({'direction':_0x04c6('0xa5'),'read':![],'body':_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][0x0][_0x04c6('0xa6')],'FaxAccountId':_0x3800b2['id'],'FaxInteractionId':_0x7eff69['id'],'UserId':_0x1fdda1[_0x04c6('0x57')]['id'],'ContactId':_0x7eff69[_0x04c6('0xa9')],'AttachmentId':_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][0x0]['id']})[_0x04c6('0x32')](function(_0xdf2e0f){_0x7eff69[_0x04c6('0xaa')]['Messages']=[];_0x7eff69[_0x04c6('0xaa')][_0x04c6('0xab')][_0x04c6('0x83')](_0xdf2e0f[_0x04c6('0xaa')]);return _0x7eff69;});})[_0x04c6('0x32')](function(_0x266dd6){respondWithRpcPromise(_0x04c6('0xac'),_0x04c6('0xac'),{'FaxAccountId':_[_0x04c6('0xa1')](_0x1fdda1[_0x04c6('0x53')]['id'])?undefined:_0x1fdda1[_0x04c6('0x53')]['id'],'path':_[_0x04c6('0xa1')](_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][0x0]['path'])?undefined:_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][0x0]['path'],'fax':_['isNil'](_0x1fdda1[_0x04c6('0x56')]['to'][0x0])?undefined:_0x1fdda1['body']['to'][0x0],'AttachmentId':_0x1fdda1[_0x04c6('0x56')][_0x04c6('0x9b')][0x0]['id']},client9002)['then'](function(_0x3e27af){logger['info'](_0x04c6('0xad'),_0x3e27af);})['catch'](function(_0x1c0f01){logger[_0x04c6('0x25')](_0x04c6('0xad'),_0x1c0f01);});return _0x266dd6;})[_0x04c6('0x32')](respondWithResult(_0x43d4b1,null))[_0x04c6('0x27')](handleError(_0x43d4b1,null));};exports[_0x04c6('0xae')]=function(_0x2f60b9,_0x20e702,_0x4b077a){return db['FaxAccount'][_0x04c6('0x54')]({'where':{'id':_0x2f60b9[_0x04c6('0x53')]['id']}})['then'](handleEntityNotFound(_0x20e702,null))['then'](function(_0x32bbdb){if(_0x32bbdb){return _0x32bbdb[_0x04c6('0xae')](_0x2f60b9['body'][_0x04c6('0x65')],_['omit'](_0x2f60b9['body'],[_0x04c6('0x65'),'id'])||{})[_0x04c6('0xa8')](function(_0x4b4acd){for(var _0x385d31=0x0;_0x385d31<_0x2f60b9[_0x04c6('0x56')][_0x04c6('0x65')][_0x04c6('0x44')];_0x385d31+=0x1){socket[_0x04c6('0xaf')]('userFaxAccount:save',{'UserId':_0x2f60b9[_0x04c6('0x56')][_0x04c6('0x65')][_0x385d31],'FaxAccountId':_0x2f60b9[_0x04c6('0x53')]['id']});}return _0x4b4acd;});}})['then'](respondWithResult(_0x20e702,null))['catch'](handleError(_0x20e702,null));};exports[_0x04c6('0xb0')]=function(_0x3fd6f9,_0x37281c,_0x41960d){return db['FaxAccount']['find']({'where':{'id':_0x3fd6f9[_0x04c6('0x53')]['id']}})[_0x04c6('0x32')](handleEntityNotFound(_0x37281c,null))[_0x04c6('0x32')](function(_0x5af843){if(_0x5af843){return _0x5af843[_0x04c6('0xb0')](_0x3fd6f9[_0x04c6('0x3e')][_0x04c6('0x65')])['then'](function(){if(_[_0x04c6('0xb1')](_0x3fd6f9[_0x04c6('0x3e')][_0x04c6('0x65')])){for(var _0x76608e=0x0;_0x76608e<_0x3fd6f9['query'][_0x04c6('0x65')][_0x04c6('0x44')];_0x76608e+=0x1){socket['emit'](_0x04c6('0xb2'),{'UserId':Number(_0x3fd6f9[_0x04c6('0x3e')]['ids'][_0x76608e]),'FaxAccountId':Number(_0x3fd6f9[_0x04c6('0x53')]['id'])});}}else{socket[_0x04c6('0xaf')]('userFaxAccount:remove',{'UserId':Number(_0x3fd6f9[_0x04c6('0x3e')][_0x04c6('0x65')]),'FaxAccountId':Number(_0x3fd6f9[_0x04c6('0x53')]['id'])});}});}})['then'](respondWithStatusCode(_0x37281c,null))[_0x04c6('0x27')](handleError(_0x37281c,null));};exports[_0x04c6('0xb3')]=function(_0x2c3565,_0x3f62dc,_0x4b9df5){var _0x4eb798={};var _0x13baa1={};var _0x2cdb5b;var _0x5862e7;return db['FaxAccount']['findOne']({'where':{'id':_0x2c3565[_0x04c6('0x53')]['id']}})['then'](handleEntityNotFound(_0x3f62dc,null))[_0x04c6('0x32')](function(_0x2af5d9){if(_0x2af5d9){_0x2cdb5b=_0x2af5d9;_0x13baa1['model']=_[_0x04c6('0x3f')](db[_0x04c6('0xb4')]['rawAttributes']);_0x13baa1[_0x04c6('0x3e')]=_[_0x04c6('0x3f')](_0x2c3565[_0x04c6('0x3e')]);_0x13baa1[_0x04c6('0x40')]=_[_0x04c6('0x41')](_0x13baa1[_0x04c6('0x3d')],_0x13baa1[_0x04c6('0x3e')]);_0x4eb798['attributes']=_[_0x04c6('0x41')](_0x13baa1[_0x04c6('0x3d')],qs[_0x04c6('0x43')](_0x2c3565[_0x04c6('0x3e')]['fields']));_0x4eb798[_0x04c6('0x42')]=_0x4eb798[_0x04c6('0x42')][_0x04c6('0x44')]?_0x4eb798[_0x04c6('0x42')]:_0x13baa1[_0x04c6('0x3d')];_0x4eb798[_0x04c6('0x47')]=qs[_0x04c6('0x48')](_0x2c3565[_0x04c6('0x3e')]['sort']);_0x4eb798[_0x04c6('0x49')]=qs[_0x04c6('0x40')](_['pick'](_0x2c3565[_0x04c6('0x3e')],_0x13baa1[_0x04c6('0x40')]));if(_0x2c3565[_0x04c6('0x3e')][_0x04c6('0x4b')]){_0x4eb798[_0x04c6('0x49')]=_['merge'](_0x4eb798[_0x04c6('0x49')],{'$or':_[_0x04c6('0x39')](_0x4eb798[_0x04c6('0x42')],function(_0xf03fa5){var _0x423360={};_0x423360[_0xf03fa5]={'$like':'%'+_0x2c3565['query']['filter']+'%'};return _0x423360;})});}_0x4eb798=_['merge']({},_0x4eb798,_0x2c3565['options']);return _0x2cdb5b[_0x04c6('0xb3')](_0x4eb798);}})[_0x04c6('0x32')](function(_0x24c564){if(_0x24c564){_0x5862e7=_0x24c564['length'];if(!_0x2c3565[_0x04c6('0x3e')][_0x04c6('0x45')]('nolimit')){_0x4eb798[_0x04c6('0x2d')]=qs[_0x04c6('0x2d')](_0x2c3565[_0x04c6('0x3e')][_0x04c6('0x2d')]);_0x4eb798[_0x04c6('0x2c')]=qs[_0x04c6('0x2c')](_0x2c3565[_0x04c6('0x3e')][_0x04c6('0x2c')]);}return _0x2cdb5b[_0x04c6('0xb3')](_0x4eb798);}})[_0x04c6('0x32')](function(_0x2b7662){if(_0x2b7662){return _0x2b7662?{'count':_0x5862e7,'rows':_0x2b7662}:null;}})['then'](respondWithResult(_0x3f62dc,null))[_0x04c6('0x27')](handleError(_0x3f62dc,null));};
\ No newline at end of file
+var _0x5f2f=['order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','rows','show','params','include','find','create','user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','Pause','describe','addDisposition','FaxAccountId','Disposition','getDispositions','findOne','findAll','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','FaxInteraction','omit','getInteractions','CmContact','Contact','Owner','fullname','internal','Tag','Tags','color','tag','sequelize','transaction','FaxApplication','bulkCreate','getApplications','context','from-voip-provider','exten','app','description','Fax\x20Extension','priority','appdata','push','Answer','Set','ecm','gateway','faxdetect','maxrate','minrate','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','VoiceExtension','updateAccountApplications','tech','key','createdAt','updatedAt','TrunkId','ListId','findById','getMessages','FaxMessage','$gte','split','YYYY-MM-DD\x20HH:mm:ss','CmList','Contacts','attachments','join','root','server/files/attachments','basename','CheckAfterSend','isNil','path','from','\x22%s\x22\x20<%s>','fax','List','List\x20not\x20found','Send\x20Fax\x20failed','Contact\x20not\x20found','spread','out','filename','dataValues','Messages','SendFax','SendFaxRpc,\x20%s','addAgents','emit','removeAgents','userFaxAccount:remove','User','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','./faxAccount.socket','register','jayson/promise','client','http','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','sendStatus','end','status','json','count','offset','limit','reject','save','update','destroy','get','FaxAccounts','UserProfileResource','stack','name','send','index','map','FaxAccount','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit'];(function(_0x4ca92a,_0x4a2b42){var _0x12a5a8=function(_0x14591f){while(--_0x14591f){_0x4ca92a['push'](_0x4ca92a['shift']());}};_0x12a5a8(++_0x4a2b42);}(_0x5f2f,0x73));var _0xf5f2=function(_0x170c5e,_0x19cd2d){_0x170c5e=_0x170c5e-0x0;var _0x182d10=_0x5f2f[_0x170c5e];return _0x182d10;};'use strict';var emlformat=require(_0xf5f2('0x0'));var rimraf=require(_0xf5f2('0x1'));var zipdir=require(_0xf5f2('0x2'));var jsonpatch=require(_0xf5f2('0x3'));var rp=require(_0xf5f2('0x4'));var moment=require(_0xf5f2('0x5'));var BPromise=require(_0xf5f2('0x6'));var Mustache=require(_0xf5f2('0x7'));var util=require('util');var path=require('path');var sox=require(_0xf5f2('0x8'));var csv=require(_0xf5f2('0x9'));var ejs=require(_0xf5f2('0xa'));var fs=require('fs');var fs_extra=require(_0xf5f2('0xb'));var _=require(_0xf5f2('0xc'));var squel=require(_0xf5f2('0xd'));var crypto=require('crypto');var jsforce=require(_0xf5f2('0xe'));var deskjs=require(_0xf5f2('0xf'));var toCsv=require(_0xf5f2('0x9'));var querystring=require('querystring');var Papa=require(_0xf5f2('0x10'));var Redis=require(_0xf5f2('0x11'));var authService=require(_0xf5f2('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xf5f2('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf5f2('0x14'));var utils=require(_0xf5f2('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf5f2('0x16'));var db=require(_0xf5f2('0x17'))['db'];config[_0xf5f2('0x18')]=_[_0xf5f2('0x19')](config[_0xf5f2('0x18')],{'host':_0xf5f2('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf5f2('0x18')]));require(_0xf5f2('0x1b'))[_0xf5f2('0x1c')](socket);var jayson=require(_0xf5f2('0x1d'));var client=jayson[_0xf5f2('0x1e')]['http']({'port':0x232c});var client9002=jayson[_0xf5f2('0x1e')][_0xf5f2('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x17d656,_0x1b6dd2,_0x23e23a,_0x3a9dbb){return new BPromise(function(_0xdb61b3,_0x395a5a){var _0x11f702=_0x3a9dbb||client;return _0x11f702[_0xf5f2('0x20')](_0x17d656,_0x23e23a)[_0xf5f2('0x21')](function(_0x28e097){logger[_0xf5f2('0x22')](_0xf5f2('0x23'),_0x1b6dd2,_0xf5f2('0x24'));logger[_0xf5f2('0x25')](_0xf5f2('0x26'),_0x1b6dd2,'request\x20sent',JSON[_0xf5f2('0x27')](_0x28e097));if(_0x28e097[_0xf5f2('0x28')]){if(_0x28e097['error']['code']===0x1f4){logger[_0xf5f2('0x28')](_0xf5f2('0x23'),_0x1b6dd2,_0x28e097['error'][_0xf5f2('0x29')]);return _0x395a5a(_0x28e097[_0xf5f2('0x28')][_0xf5f2('0x29')]);}logger[_0xf5f2('0x28')](_0xf5f2('0x23'),_0x1b6dd2,_0x28e097['error'][_0xf5f2('0x29')]);return _0xdb61b3(_0x28e097[_0xf5f2('0x28')][_0xf5f2('0x29')]);}else{logger[_0xf5f2('0x22')](_0xf5f2('0x23'),_0x1b6dd2,'request\x20sent');_0xdb61b3(_0x28e097['result'][_0xf5f2('0x29')]);}})[_0xf5f2('0x2a')](function(_0x13da6f){logger[_0xf5f2('0x28')](_0xf5f2('0x23'),_0x1b6dd2,_0x13da6f);_0x395a5a(_0x13da6f);});});}function respondWithStatusCode(_0x788a8d,_0x13a3be){_0x13a3be=_0x13a3be||0xcc;return function(_0x281ec8){if(_0x281ec8){return _0x788a8d[_0xf5f2('0x2b')](_0x13a3be);}return _0x788a8d['status'](_0x13a3be)[_0xf5f2('0x2c')]();};}function respondWithResult(_0x102449,_0x375ca8){_0x375ca8=_0x375ca8||0xc8;return function(_0x31bfcb){if(_0x31bfcb){return _0x102449[_0xf5f2('0x2d')](_0x375ca8)[_0xf5f2('0x2e')](_0x31bfcb);}};}function respondWithFilteredResult(_0x5b6672,_0x53cb96){return function(_0x22c826){if(_0x22c826){var _0x14c829=_0x22c826[_0xf5f2('0x2f')],_0x11c771=_0x53cb96[_0xf5f2('0x30')],_0x5027ab=_0x53cb96[_0xf5f2('0x30')]+_0x53cb96[_0xf5f2('0x31')],_0x5a2c7e;if(_0x5027ab>=_0x14c829){_0x5027ab=_0x14c829;_0x5a2c7e=0xc8;}else{_0x5a2c7e=0xce;}_0x5b6672[_0xf5f2('0x2d')](_0x5a2c7e);return _0x5b6672['set']('Content-Range',_0x11c771+'-'+_0x5027ab+'/'+_0x14c829)[_0xf5f2('0x2e')](_0x22c826);}return null;};}function patchUpdates(_0x4e19cb){return function(_0xb744b9){try{jsonpatch['apply'](_0xb744b9,_0x4e19cb,!![]);}catch(_0x45b643){return BPromise[_0xf5f2('0x32')](_0x45b643);}return _0xb744b9[_0xf5f2('0x33')]();};}function saveUpdates(_0x428770,_0x256bd9){return function(_0x277eee){if(_0x277eee){return _0x277eee[_0xf5f2('0x34')](_0x428770)[_0xf5f2('0x21')](function(_0x5ca917){return _0x5ca917;});}return null;};}function removeEntity(_0x4149e6,_0x43e4ff){return function(_0x4590ec){if(_0x4590ec){return _0x4590ec[_0xf5f2('0x35')]()[_0xf5f2('0x21')](function(){var _0x27c0e7=_0x4590ec[_0xf5f2('0x36')]({'plain':!![]});var _0x48d64d=_0xf5f2('0x37');return db[_0xf5f2('0x38')]['destroy']({'where':{'type':_0x48d64d,'resourceId':_0x27c0e7['id']}})[_0xf5f2('0x21')](function(){return _0x4590ec;});})['then'](function(){_0x4149e6[_0xf5f2('0x2d')](0xcc)[_0xf5f2('0x2c')]();});}};}function handleEntityNotFound(_0x2a2c31,_0x2e3cca){return function(_0x59a6dd){if(!_0x59a6dd){_0x2a2c31['sendStatus'](0x194);}return _0x59a6dd;};}function handleError(_0x41088b,_0x46ad4a){_0x46ad4a=_0x46ad4a||0x1f4;return function(_0x20eb74){logger['error'](_0x20eb74[_0xf5f2('0x39')]);if(_0x20eb74['name']){delete _0x20eb74[_0xf5f2('0x3a')];}_0x41088b['status'](_0x46ad4a)[_0xf5f2('0x3b')](_0x20eb74);};}exports[_0xf5f2('0x3c')]=function(_0x5337a6,_0x29694f){var _0x46eb22={'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x5a4441={},_0x35f738={'count':0x0,'rows':[]};var _0x3d328f=_[_0xf5f2('0x3d')](db[_0xf5f2('0x3e')][_0xf5f2('0x3f')],function(_0x2c7f65){return{'name':_0x2c7f65[_0xf5f2('0x40')],'type':_0x2c7f65[_0xf5f2('0x41')]['key']};});_0x5a4441[_0xf5f2('0x42')]=_[_0xf5f2('0x3d')](_0x3d328f,'name');_0x5a4441[_0xf5f2('0x43')]=_[_0xf5f2('0x44')](_0x5337a6[_0xf5f2('0x43')]);_0x5a4441[_0xf5f2('0x45')]=_[_0xf5f2('0x46')](_0x5a4441[_0xf5f2('0x42')],_0x5a4441[_0xf5f2('0x43')]);_0x46eb22[_0xf5f2('0x47')]=_['intersection'](_0x5a4441[_0xf5f2('0x42')],qs[_0xf5f2('0x48')](_0x5337a6[_0xf5f2('0x43')]['fields']));_0x46eb22['attributes']=_0x46eb22['attributes'][_0xf5f2('0x49')]?_0x46eb22[_0xf5f2('0x47')]:_0x5a4441['model'];if(!_0x5337a6[_0xf5f2('0x43')][_0xf5f2('0x4a')](_0xf5f2('0x4b'))){_0x46eb22[_0xf5f2('0x31')]=qs[_0xf5f2('0x31')](_0x5337a6[_0xf5f2('0x43')][_0xf5f2('0x31')]);_0x46eb22[_0xf5f2('0x30')]=qs[_0xf5f2('0x30')](_0x5337a6[_0xf5f2('0x43')][_0xf5f2('0x30')]);}_0x46eb22[_0xf5f2('0x4c')]=qs[_0xf5f2('0x4d')](_0x5337a6[_0xf5f2('0x43')]['sort']);_0x46eb22[_0xf5f2('0x4e')]=qs['filters'](_[_0xf5f2('0x4f')](_0x5337a6[_0xf5f2('0x43')],_0x5a4441[_0xf5f2('0x45')]),_0x3d328f);if(_0x5337a6[_0xf5f2('0x43')][_0xf5f2('0x50')]){_0x46eb22[_0xf5f2('0x4e')]=_['merge'](_0x46eb22[_0xf5f2('0x4e')],{'$or':_[_0xf5f2('0x3d')](_0x3d328f,function(_0x1c1497){if(_0x1c1497[_0xf5f2('0x41')]!==_0xf5f2('0x51')){var _0x10753a={};_0x10753a[_0x1c1497[_0xf5f2('0x3a')]]={'$like':'%'+_0x5337a6[_0xf5f2('0x43')]['filter']+'%'};return _0x10753a;}})});}_0x46eb22=_[_0xf5f2('0x52')]({},_0x46eb22,_0x5337a6[_0xf5f2('0x53')]);var _0x45db9a={'where':_0x46eb22['where']};return db[_0xf5f2('0x3e')][_0xf5f2('0x2f')](_0x45db9a)[_0xf5f2('0x21')](function(_0x5e761c){_0x35f738['count']=_0x5e761c;if(_0x5337a6[_0xf5f2('0x43')][_0xf5f2('0x54')]){_0x46eb22['include']=[{'all':!![]}];}return db[_0xf5f2('0x3e')]['findAll'](_0x46eb22);})[_0xf5f2('0x21')](function(_0x497eb8){_0x35f738[_0xf5f2('0x55')]=_0x497eb8;return _0x35f738;})['then'](respondWithFilteredResult(_0x29694f,_0x46eb22))[_0xf5f2('0x2a')](handleError(_0x29694f,null));};exports[_0xf5f2('0x56')]=function(_0xbb658c,_0x11a083){var _0x4fa738={'raw':![],'where':{'id':_0xbb658c[_0xf5f2('0x57')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x3154c1={};_0x3154c1[_0xf5f2('0x42')]=_[_0xf5f2('0x44')](db['FaxAccount'][_0xf5f2('0x3f')]);_0x3154c1[_0xf5f2('0x43')]=_[_0xf5f2('0x44')](_0xbb658c[_0xf5f2('0x43')]);_0x3154c1['filters']=_['intersection'](_0x3154c1[_0xf5f2('0x42')],_0x3154c1[_0xf5f2('0x43')]);_0x4fa738['attributes']=_[_0xf5f2('0x46')](_0x3154c1[_0xf5f2('0x42')],qs[_0xf5f2('0x48')](_0xbb658c[_0xf5f2('0x43')][_0xf5f2('0x48')]));_0x4fa738[_0xf5f2('0x47')]=_0x4fa738[_0xf5f2('0x47')]['length']?_0x4fa738['attributes']:_0x3154c1[_0xf5f2('0x42')];if(_0xbb658c[_0xf5f2('0x43')][_0xf5f2('0x54')]){_0x4fa738[_0xf5f2('0x58')]=[{'all':!![]}];}_0x4fa738=_[_0xf5f2('0x52')]({},_0x4fa738,_0xbb658c['options']);return db[_0xf5f2('0x3e')][_0xf5f2('0x59')](_0x4fa738)[_0xf5f2('0x21')](handleEntityNotFound(_0x11a083,null))['then'](respondWithResult(_0x11a083,null))[_0xf5f2('0x2a')](handleError(_0x11a083,null));};exports['create']=function(_0x78f1d2,_0x1a8d33){return db[_0xf5f2('0x3e')][_0xf5f2('0x5a')](_0x78f1d2['body'],{})['then'](function(_0x756f1f){var _0x4de303=_0x78f1d2[_0xf5f2('0x5b')][_0xf5f2('0x36')]({'plain':!![]});if(!_0x4de303)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4de303[_0xf5f2('0x5c')]===_0xf5f2('0x5b')){var _0x2a8f6d=_0x756f1f['get']({'plain':!![]});var _0x397b99=_0xf5f2('0x37');return db[_0xf5f2('0x5d')][_0xf5f2('0x59')]({'where':{'name':_0x397b99,'userProfileId':_0x4de303['userProfileId']},'raw':!![]})[_0xf5f2('0x21')](function(_0x506fe5){if(_0x506fe5&&_0x506fe5[_0xf5f2('0x5e')]===0x0){return db[_0xf5f2('0x38')][_0xf5f2('0x5a')]({'name':_0x2a8f6d[_0xf5f2('0x3a')],'resourceId':_0x2a8f6d['id'],'type':_0x506fe5[_0xf5f2('0x3a')],'sectionId':_0x506fe5['id']},{})['then'](function(){return _0x756f1f;});}else{return _0x756f1f;}})[_0xf5f2('0x2a')](function(_0xacd80){logger[_0xf5f2('0x28')](_0xf5f2('0x5f'),_0xacd80);throw _0xacd80;});}return _0x756f1f;})[_0xf5f2('0x21')](respondWithResult(_0x1a8d33,0xc9))['catch'](handleError(_0x1a8d33,null));};exports[_0xf5f2('0x34')]=function(_0x5ee6bc,_0x4c96ee){if(_0x5ee6bc[_0xf5f2('0x60')]['id']){delete _0x5ee6bc['body']['id'];}return db[_0xf5f2('0x3e')][_0xf5f2('0x59')]({'where':{'id':_0x5ee6bc[_0xf5f2('0x57')]['id']},'include':[{'model':db[_0xf5f2('0x61')],'as':'mandatoryDispositionPause'}]})[_0xf5f2('0x21')](handleEntityNotFound(_0x4c96ee,null))[_0xf5f2('0x21')](saveUpdates(_0x5ee6bc[_0xf5f2('0x60')],null))[_0xf5f2('0x21')](respondWithResult(_0x4c96ee,null))[_0xf5f2('0x2a')](handleError(_0x4c96ee,null));};exports[_0xf5f2('0x35')]=function(_0x158768,_0x4a7be9){return db[_0xf5f2('0x3e')][_0xf5f2('0x59')]({'where':{'id':_0x158768[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x4a7be9,null))['then'](removeEntity(_0x4a7be9,null))[_0xf5f2('0x2a')](handleError(_0x4a7be9,null));};exports['describe']=function(_0x410866,_0x1c7f06){return db['FaxAccount'][_0xf5f2('0x62')]()[_0xf5f2('0x21')](respondWithResult(_0x1c7f06,null))[_0xf5f2('0x2a')](handleError(_0x1c7f06,null));};exports[_0xf5f2('0x63')]=function(_0x146462,_0x4bd113,_0x3e821c){if(_0x146462[_0xf5f2('0x60')]['id']){delete _0x146462[_0xf5f2('0x60')]['id'];}return db[_0xf5f2('0x3e')][_0xf5f2('0x59')]({'where':{'id':_0x146462[_0xf5f2('0x57')]['id']}})['then'](handleEntityNotFound(_0x4bd113,null))[_0xf5f2('0x21')](function(_0x3f475e){if(_0x3f475e){_0x146462['body'][_0xf5f2('0x64')]=_0x3f475e['id'];return db[_0xf5f2('0x65')][_0xf5f2('0x5a')](_0x146462['body']);}})['then'](respondWithResult(_0x4bd113,null))['catch'](handleError(_0x4bd113,null));};exports[_0xf5f2('0x66')]=function(_0x35f3f6,_0x35f6a2,_0x450691){var _0x55da4d={'raw':![],'where':{}};var _0x4d878e={};var _0x278b76={'count':0x0,'rows':[]};return db[_0xf5f2('0x3e')][_0xf5f2('0x67')]({'where':{'id':_0x35f3f6[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x35f6a2,null))[_0xf5f2('0x21')](function(_0x11c302){if(_0x11c302){_0x4d878e[_0xf5f2('0x42')]=_[_0xf5f2('0x44')](db[_0xf5f2('0x65')][_0xf5f2('0x3f')]);_0x4d878e['query']=_['keys'](_0x35f3f6['query']);_0x4d878e[_0xf5f2('0x45')]=_[_0xf5f2('0x46')](_0x4d878e[_0xf5f2('0x42')],_0x4d878e[_0xf5f2('0x43')]);_0x55da4d[_0xf5f2('0x47')]=_['intersection'](_0x4d878e[_0xf5f2('0x42')],qs[_0xf5f2('0x48')](_0x35f3f6[_0xf5f2('0x43')][_0xf5f2('0x48')]));_0x55da4d[_0xf5f2('0x47')]=_0x55da4d['attributes'][_0xf5f2('0x49')]?_0x55da4d[_0xf5f2('0x47')]:_0x4d878e['model'];if(!_0x35f3f6[_0xf5f2('0x43')][_0xf5f2('0x4a')](_0xf5f2('0x4b'))){_0x55da4d[_0xf5f2('0x31')]=qs['limit'](_0x35f3f6[_0xf5f2('0x43')][_0xf5f2('0x31')]);_0x55da4d[_0xf5f2('0x30')]=qs[_0xf5f2('0x30')](_0x35f3f6[_0xf5f2('0x43')]['offset']);}_0x55da4d['order']=qs[_0xf5f2('0x4d')](_0x35f3f6[_0xf5f2('0x43')][_0xf5f2('0x4d')]);_0x55da4d[_0xf5f2('0x4e')]=qs['filters'](_['pick'](_0x35f3f6[_0xf5f2('0x43')],_0x4d878e['filters']));_0x55da4d['where']['FaxAccountId']=_0x11c302['id'];if(_0x35f3f6['query'][_0xf5f2('0x50')]){_0x55da4d[_0xf5f2('0x4e')]=_[_0xf5f2('0x52')](_0x55da4d[_0xf5f2('0x4e')],{'$or':_[_0xf5f2('0x3d')](_0x55da4d[_0xf5f2('0x47')],function(_0x164cc6){var _0x3341be={};_0x3341be[_0x164cc6]={'$like':'%'+_0x35f3f6[_0xf5f2('0x43')][_0xf5f2('0x50')]+'%'};return _0x3341be;})});}_0x55da4d=_[_0xf5f2('0x52')]({},_0x55da4d,_0x35f3f6[_0xf5f2('0x53')]);return db[_0xf5f2('0x65')][_0xf5f2('0x2f')]({'where':_0x55da4d[_0xf5f2('0x4e')]})[_0xf5f2('0x21')](function(_0x154a8b){_0x278b76[_0xf5f2('0x2f')]=_0x154a8b;if(_0x35f3f6['query'][_0xf5f2('0x54')]){_0x55da4d[_0xf5f2('0x58')]=[{'all':!![]}];}return db[_0xf5f2('0x65')][_0xf5f2('0x68')](_0x55da4d);})[_0xf5f2('0x21')](function(_0x308220){_0x278b76[_0xf5f2('0x55')]=_0x308220;return _0x278b76;});}})[_0xf5f2('0x21')](respondWithFilteredResult(_0x35f6a2,_0x55da4d))['catch'](handleError(_0x35f6a2,null));};exports[_0xf5f2('0x69')]=function(_0x57b50f,_0x4bc51a,_0x5bf3b9){return db['FaxAccount']['find']({'where':{'id':_0x57b50f['params']['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x4bc51a,null))[_0xf5f2('0x21')](function(_0x26a57c){if(_0x26a57c){return _0x26a57c[_0xf5f2('0x69')](_0x57b50f[_0xf5f2('0x43')][_0xf5f2('0x6a')]);}})['then'](respondWithStatusCode(_0x4bc51a,null))['catch'](handleError(_0x4bc51a,null));};exports[_0xf5f2('0x6b')]=function(_0x578a22,_0x418ece,_0x186fdd){if(_0x578a22['body']['id']){delete _0x578a22['body']['id'];}return db[_0xf5f2('0x3e')][_0xf5f2('0x59')]({'where':{'id':_0x578a22['params']['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x418ece,null))[_0xf5f2('0x21')](function(_0x49e363){if(_0x49e363){_0x578a22[_0xf5f2('0x60')][_0xf5f2('0x64')]=_0x49e363['id'];return db[_0xf5f2('0x6c')]['create'](_0x578a22[_0xf5f2('0x60')]);}})[_0xf5f2('0x21')](respondWithResult(_0x418ece,null))[_0xf5f2('0x2a')](handleError(_0x418ece,null));};exports[_0xf5f2('0x6d')]=function(_0x3e188e,_0x3e0288,_0x25974b){var _0x379053={'raw':![],'where':{}};var _0x25ec54={};var _0x3a6f60={'count':0x0,'rows':[]};return db[_0xf5f2('0x3e')][_0xf5f2('0x67')]({'where':{'id':_0x3e188e[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x3e0288,null))[_0xf5f2('0x21')](function(_0x28b9cd){if(_0x28b9cd){_0x25ec54[_0xf5f2('0x42')]=_[_0xf5f2('0x44')](db[_0xf5f2('0x6c')][_0xf5f2('0x3f')]);_0x25ec54[_0xf5f2('0x43')]=_['keys'](_0x3e188e[_0xf5f2('0x43')]);_0x25ec54[_0xf5f2('0x45')]=_['intersection'](_0x25ec54[_0xf5f2('0x42')],_0x25ec54[_0xf5f2('0x43')]);_0x379053['attributes']=_[_0xf5f2('0x46')](_0x25ec54[_0xf5f2('0x42')],qs[_0xf5f2('0x48')](_0x3e188e['query']['fields']));_0x379053[_0xf5f2('0x47')]=_0x379053[_0xf5f2('0x47')][_0xf5f2('0x49')]?_0x379053['attributes']:_0x25ec54['model'];if(!_0x3e188e[_0xf5f2('0x43')][_0xf5f2('0x4a')](_0xf5f2('0x4b'))){_0x379053['limit']=qs['limit'](_0x3e188e['query']['limit']);_0x379053['offset']=qs[_0xf5f2('0x30')](_0x3e188e['query'][_0xf5f2('0x30')]);}_0x379053[_0xf5f2('0x4c')]=qs[_0xf5f2('0x4d')](_0x3e188e[_0xf5f2('0x43')][_0xf5f2('0x4d')]);_0x379053[_0xf5f2('0x4e')]=qs[_0xf5f2('0x45')](_[_0xf5f2('0x4f')](_0x3e188e[_0xf5f2('0x43')],_0x25ec54[_0xf5f2('0x45')]));_0x379053[_0xf5f2('0x4e')][_0xf5f2('0x64')]=_0x28b9cd['id'];if(_0x3e188e[_0xf5f2('0x43')]['filter']){_0x379053[_0xf5f2('0x4e')]=_[_0xf5f2('0x52')](_0x379053['where'],{'$or':_[_0xf5f2('0x3d')](_0x379053[_0xf5f2('0x47')],function(_0x537a7d){var _0x433ba0={};_0x433ba0[_0x537a7d]={'$like':'%'+_0x3e188e[_0xf5f2('0x43')][_0xf5f2('0x50')]+'%'};return _0x433ba0;})});}_0x379053=_['merge']({},_0x379053,_0x3e188e[_0xf5f2('0x53')]);return db[_0xf5f2('0x6c')]['count']({'where':_0x379053[_0xf5f2('0x4e')]})[_0xf5f2('0x21')](function(_0x41bf8c){_0x3a6f60['count']=_0x41bf8c;if(_0x3e188e[_0xf5f2('0x43')]['includeAll']){_0x379053[_0xf5f2('0x58')]=[{'all':!![]}];}return db['CannedAnswer'][_0xf5f2('0x68')](_0x379053);})[_0xf5f2('0x21')](function(_0x120e2b){_0x3a6f60[_0xf5f2('0x55')]=_0x120e2b;return _0x3a6f60;});}})['then'](respondWithFilteredResult(_0x3e0288,_0x379053))[_0xf5f2('0x2a')](handleError(_0x3e0288,null));};exports['removeAnswers']=function(_0x52e037,_0x4b4d7f,_0x2a253a){return db[_0xf5f2('0x3e')]['find']({'where':{'id':_0x52e037[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x4b4d7f,null))[_0xf5f2('0x21')](function(_0x3962b2){if(_0x3962b2){return _0x3962b2[_0xf5f2('0x6e')](_0x52e037[_0xf5f2('0x43')]['ids']);}})[_0xf5f2('0x21')](respondWithStatusCode(_0x4b4d7f,null))[_0xf5f2('0x2a')](handleError(_0x4b4d7f,null));};exports['addInteraction']=function(_0x22865e,_0x19cbff,_0x58042c){return db[_0xf5f2('0x6f')][_0xf5f2('0x59')]({'where':{'id':_0x22865e[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x19cbff,null))[_0xf5f2('0x21')](function(_0x28dd0c){if(_0x28dd0c){return _0x28dd0c['addInteraction'](_0x22865e[_0xf5f2('0x60')][_0xf5f2('0x6a')],_[_0xf5f2('0x70')](_0x22865e[_0xf5f2('0x60')],[_0xf5f2('0x6a'),'id'])||{});}})[_0xf5f2('0x21')](respondWithResult(_0x19cbff,null))[_0xf5f2('0x2a')](handleError(_0x19cbff,null));};exports[_0xf5f2('0x71')]=function(_0x3e4e40,_0x5cabb2,_0x35408a){var _0x3d3b9b={'raw':![],'where':{}};var _0xdbb2cd={};var _0x934a7d={'count':0x0,'rows':[]};return db[_0xf5f2('0x3e')][_0xf5f2('0x67')]({'where':{'id':_0x3e4e40[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x5cabb2,null))[_0xf5f2('0x21')](function(_0x40d0eb){if(_0x40d0eb){_0xdbb2cd['model']=_['keys'](db[_0xf5f2('0x6f')][_0xf5f2('0x3f')]);_0xdbb2cd[_0xf5f2('0x43')]=_[_0xf5f2('0x44')](_0x3e4e40['query']);_0xdbb2cd[_0xf5f2('0x45')]=_[_0xf5f2('0x46')](_0xdbb2cd[_0xf5f2('0x42')],_0xdbb2cd[_0xf5f2('0x43')]);_0x3d3b9b[_0xf5f2('0x47')]=_['intersection'](_0xdbb2cd[_0xf5f2('0x42')],qs[_0xf5f2('0x48')](_0x3e4e40['query'][_0xf5f2('0x48')]));_0x3d3b9b[_0xf5f2('0x47')]=_0x3d3b9b[_0xf5f2('0x47')][_0xf5f2('0x49')]?_0x3d3b9b['attributes']:_0xdbb2cd[_0xf5f2('0x42')];if(!_0x3e4e40[_0xf5f2('0x43')][_0xf5f2('0x4a')]('nolimit')){_0x3d3b9b['limit']=qs[_0xf5f2('0x31')](_0x3e4e40[_0xf5f2('0x43')][_0xf5f2('0x31')]);_0x3d3b9b[_0xf5f2('0x30')]=qs[_0xf5f2('0x30')](_0x3e4e40[_0xf5f2('0x43')]['offset']);}_0x3d3b9b[_0xf5f2('0x4c')]=qs['sort'](_0x3e4e40[_0xf5f2('0x43')][_0xf5f2('0x4d')]);_0x3d3b9b[_0xf5f2('0x4e')]=qs[_0xf5f2('0x45')](_[_0xf5f2('0x4f')](_0x3e4e40[_0xf5f2('0x43')],_0xdbb2cd['filters']));_0x3d3b9b[_0xf5f2('0x4e')][_0xf5f2('0x64')]=_0x40d0eb['id'];if(_0x3e4e40[_0xf5f2('0x43')][_0xf5f2('0x50')]){_0x3d3b9b[_0xf5f2('0x4e')]=_[_0xf5f2('0x52')](_0x3d3b9b[_0xf5f2('0x4e')],{'$or':_['map'](_0x3d3b9b[_0xf5f2('0x47')],function(_0x4a6b83){var _0x5857d1={};_0x5857d1[_0x4a6b83]={'$like':'%'+_0x3e4e40['query'][_0xf5f2('0x50')]+'%'};return _0x5857d1;})});}_0x3d3b9b=_[_0xf5f2('0x52')]({},_0x3d3b9b,_0x3e4e40['options']);return db[_0xf5f2('0x6f')][_0xf5f2('0x2f')]({'where':_0x3d3b9b[_0xf5f2('0x4e')]})[_0xf5f2('0x21')](function(_0x4f2704){_0x934a7d[_0xf5f2('0x2f')]=_0x4f2704;if(_0x3e4e40[_0xf5f2('0x43')][_0xf5f2('0x54')]){_0x3d3b9b['include']=[{'model':db[_0xf5f2('0x72')],'as':_0xf5f2('0x73'),'required':![]},{'model':db['User'],'as':_0xf5f2('0x74'),'attributes':[_0xf5f2('0x3a'),_0xf5f2('0x75'),_0xf5f2('0x76')],'required':![]},{'model':db[_0xf5f2('0x77')],'as':_0xf5f2('0x78'),'attributes':['id',_0xf5f2('0x3a'),_0xf5f2('0x79')],'where':_0x3e4e40[_0xf5f2('0x43')][_0xf5f2('0x7a')]?{'id':_0x3e4e40[_0xf5f2('0x43')]['tag']}:undefined,'required':_0x3e4e40[_0xf5f2('0x43')][_0xf5f2('0x7a')]?!![]:![]}];}return db['FaxInteraction'][_0xf5f2('0x68')](_0x3d3b9b);})['then'](function(_0x3b2620){_0x934a7d[_0xf5f2('0x55')]=_0x3b2620;return _0x934a7d;});}})[_0xf5f2('0x21')](respondWithFilteredResult(_0x5cabb2,_0x3d3b9b))[_0xf5f2('0x2a')](handleError(_0x5cabb2,null));};exports['addApplications']=function(_0x451711,_0x5a104b,_0x55da48){return db['FaxAccount'][_0xf5f2('0x67')]({'where':{'id':_0x451711[_0xf5f2('0x57')]['id']}})['then'](handleEntityNotFound(_0x5a104b,null))[_0xf5f2('0x21')](function(_0x4525c9){if(_0x4525c9){return db[_0xf5f2('0x7b')][_0xf5f2('0x7c')](function(_0x344e90){return db[_0xf5f2('0x7d')]['destroy']({'where':{'FaxAccountId':_0x451711['params']['id']},'transaction':_0x344e90})[_0xf5f2('0x21')](function(_0x17e1eb){var _0x5dc5da=_[_0xf5f2('0x3d')](_0x451711[_0xf5f2('0x60')],function(_0xce8b64){_0xce8b64[_0xf5f2('0x64')]=_0x451711[_0xf5f2('0x57')]['id'];return _0xce8b64;});return db[_0xf5f2('0x7d')][_0xf5f2('0x7e')](_0x5dc5da,{'transaction':_0x344e90});});})['then'](function(){return db[_0xf5f2('0x7d')]['findAndCountAll']({'where':{'FaxAccountId':_0x451711[_0xf5f2('0x57')]['id']},'order':'priority'});});}})[_0xf5f2('0x21')](respondWithResult(_0x5a104b,null))['catch'](handleError(_0x5a104b,null));};exports[_0xf5f2('0x7f')]=function(_0x4d4b02,_0x51fd11,_0x2c285c){var _0x2cfb98={};var _0x57708f={};var _0x38cb63;var _0x3ebd59;return db[_0xf5f2('0x3e')][_0xf5f2('0x67')]({'where':{'id':_0x4d4b02[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x51fd11,null))[_0xf5f2('0x21')](function(_0x128f37){if(_0x128f37){_0x38cb63=_0x128f37;_0x57708f['model']=_['keys'](db[_0xf5f2('0x7d')]['rawAttributes']);_0x57708f[_0xf5f2('0x43')]=_[_0xf5f2('0x44')](_0x4d4b02[_0xf5f2('0x43')]);_0x57708f[_0xf5f2('0x45')]=_[_0xf5f2('0x46')](_0x57708f[_0xf5f2('0x42')],_0x57708f[_0xf5f2('0x43')]);_0x2cfb98[_0xf5f2('0x47')]=_[_0xf5f2('0x46')](_0x57708f[_0xf5f2('0x42')],qs[_0xf5f2('0x48')](_0x4d4b02[_0xf5f2('0x43')]['fields']));_0x2cfb98[_0xf5f2('0x47')]=_0x2cfb98['attributes'][_0xf5f2('0x49')]?_0x2cfb98[_0xf5f2('0x47')]:_0x57708f[_0xf5f2('0x42')];_0x2cfb98[_0xf5f2('0x4c')]=qs[_0xf5f2('0x4d')](_0x4d4b02[_0xf5f2('0x43')][_0xf5f2('0x4d')]);_0x2cfb98[_0xf5f2('0x4e')]=qs[_0xf5f2('0x45')](_[_0xf5f2('0x4f')](_0x4d4b02[_0xf5f2('0x43')],_0x57708f['filters']));if(_0x4d4b02[_0xf5f2('0x43')][_0xf5f2('0x50')]){_0x2cfb98[_0xf5f2('0x4e')]=_[_0xf5f2('0x52')](_0x2cfb98[_0xf5f2('0x4e')],{'$or':_[_0xf5f2('0x3d')](_0x2cfb98[_0xf5f2('0x47')],function(_0x55c37e){var _0x179995={};_0x179995[_0x55c37e]={'$like':'%'+_0x4d4b02[_0xf5f2('0x43')][_0xf5f2('0x50')]+'%'};return _0x179995;})});}_0x2cfb98=_[_0xf5f2('0x52')]({},_0x2cfb98,_0x4d4b02[_0xf5f2('0x53')]);return _0x38cb63[_0xf5f2('0x7f')](_0x2cfb98);}})[_0xf5f2('0x21')](function(_0x1167e2){if(_0x1167e2){_0x3ebd59=_0x1167e2[_0xf5f2('0x49')];if(!_0x4d4b02[_0xf5f2('0x43')][_0xf5f2('0x4a')](_0xf5f2('0x4b'))){_0x2cfb98[_0xf5f2('0x31')]=qs[_0xf5f2('0x31')](_0x4d4b02[_0xf5f2('0x43')][_0xf5f2('0x31')]);_0x2cfb98['offset']=qs[_0xf5f2('0x30')](_0x4d4b02[_0xf5f2('0x43')]['offset']);}return _0x38cb63['getApplications'](_0x2cfb98);}})[_0xf5f2('0x21')](function(_0x22a3dc){if(_0x22a3dc){return _0x22a3dc?{'count':_0x3ebd59,'rows':_0x22a3dc}:null;}})[_0xf5f2('0x21')](respondWithResult(_0x51fd11,null))[_0xf5f2('0x2a')](handleError(_0x51fd11,null));};function Extension(_0x529d6f,_0x28cc,_0x4b2082,_0x2e3189){this[_0xf5f2('0x80')]=_0xf5f2('0x81');this[_0xf5f2('0x82')]=_0x529d6f['localstationid'];this[_0xf5f2('0x83')]=_0x2e3189;this['type']='system';this[_0xf5f2('0x84')]=_0xf5f2('0x85');this[_0xf5f2('0x64')]=_0x529d6f['id'];this[_0xf5f2('0x86')]=_0x28cc;this[_0xf5f2('0x87')]=_0x4b2082;}function createExtensionsReciveFax(_0x2643dc){var _0xc3dfad=0x1;var _0x591f92=[];_0x591f92[_0xf5f2('0x88')](new Extension(_0x2643dc,_0xc3dfad,'',_0xf5f2('0x89')));_0xc3dfad+=0x1;_0x591f92[_0xf5f2('0x88')](new Extension(_0x2643dc,_0xc3dfad,'CDR(type)=inbound-fax',_0xf5f2('0x8a')));_0xc3dfad+=0x1;for(var _0x50e119 in _0x2643dc){if(_0x2643dc['hasOwnProperty'](_0x50e119)&&(_0x50e119===_0xf5f2('0x8b')||_0x50e119==='localstationid'||_0x50e119===_0xf5f2('0x8c')||_0x50e119===_0xf5f2('0x8d')||_0x50e119==='headerinfo'||_0x50e119===_0xf5f2('0x8e')||_0x50e119===_0xf5f2('0x8f')||_0x50e119==='modem'||_0x50e119===_0xf5f2('0x90'))){_0x591f92[_0xf5f2('0x88')](new Extension(_0x2643dc,_0xc3dfad,_0xf5f2('0x91')+_0x50e119+')='+_0x2643dc[_0x50e119],_0xf5f2('0x8a')));_0xc3dfad+=0x1;}}_0x591f92[_0xf5f2('0x88')](new Extension(_0x2643dc,_0xc3dfad,'6','Wait'));_0xc3dfad+=0x1;_0x591f92[_0xf5f2('0x88')](new Extension(_0x2643dc,_0xc3dfad,_0xf5f2('0x92'),'ReceiveFax'));_0xc3dfad=0x0;return _0x591f92;}exports['addAccountApplications']=function(_0x3dd6e8,_0x37f2f1,_0x2d3ed2){var _0x381d27;return db[_0xf5f2('0x7b')][_0xf5f2('0x7c')](function(_0xefa664){return db[_0xf5f2('0x3e')]['create'](_0x3dd6e8['body'],{'transaction':_0xefa664})[_0xf5f2('0x21')](function(_0x5be398){_0x381d27=_0x5be398[_0xf5f2('0x36')]({'plain':!![]});return db[_0xf5f2('0x93')][_0xf5f2('0x7e')](createExtensionsReciveFax(_0x381d27),{'transaction':_0xefa664});});})[_0xf5f2('0x21')](function(){return _0x381d27;})['then'](respondWithResult(_0x37f2f1,null))[_0xf5f2('0x2a')](handleError(_0x37f2f1,null));};exports[_0xf5f2('0x94')]=function(_0x29cb4b,_0x1ed9aa,_0x77e9b9){var _0x48f1ae;return db[_0xf5f2('0x7b')][_0xf5f2('0x7c')](function(_0x378009){return db[_0xf5f2('0x3e')][_0xf5f2('0x34')](_0x29cb4b[_0xf5f2('0x60')],{'where':{'id':_0x29cb4b[_0xf5f2('0x60')]['id']},'transaction':_0x378009})[_0xf5f2('0x21')](function(_0x25deee){return db[_0xf5f2('0x93')][_0xf5f2('0x35')]({'where':{'FaxAccountId':_0x29cb4b[_0xf5f2('0x60')]['id']},'transaction':_0x378009})['then'](function(_0xd05e21){return db['VoiceExtension'][_0xf5f2('0x7e')](createExtensionsReciveFax(_[_0xf5f2('0x70')](_0x29cb4b[_0xf5f2('0x60')],[_0xf5f2('0x95'),_0xf5f2('0x96'),_0xf5f2('0x97'),_0xf5f2('0x98'),_0xf5f2('0x99'),_0xf5f2('0x9a')])),{'transaction':_0x378009});});});})[_0xf5f2('0x21')](function(){return db[_0xf5f2('0x3e')][_0xf5f2('0x9b')](_0x29cb4b[_0xf5f2('0x60')]['id']);})[_0xf5f2('0x21')](respondWithResult(_0x1ed9aa,null))[_0xf5f2('0x2a')](handleError(_0x1ed9aa,null));};exports[_0xf5f2('0x9c')]=function(_0x1afc94,_0x33f987,_0x4cb93d){var _0x32ca19={'raw':!![],'where':{}};var _0x51573a={};var _0x5b96ef={'count':0x0,'rows':[]};return db[_0xf5f2('0x3e')][_0xf5f2('0x67')]({'where':{'id':_0x1afc94['params']['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x33f987,null))[_0xf5f2('0x21')](function(_0xb982a1){if(_0xb982a1){_0x51573a[_0xf5f2('0x42')]=_[_0xf5f2('0x44')](db[_0xf5f2('0x9d')][_0xf5f2('0x3f')]);_0x51573a[_0xf5f2('0x43')]=_['keys'](_0x1afc94[_0xf5f2('0x43')]);_0x51573a[_0xf5f2('0x45')]=_[_0xf5f2('0x46')](_0x51573a['model'],_0x51573a[_0xf5f2('0x43')]);_0x32ca19[_0xf5f2('0x47')]=_[_0xf5f2('0x46')](_0x51573a[_0xf5f2('0x42')],qs['fields'](_0x1afc94['query'][_0xf5f2('0x48')]));_0x32ca19[_0xf5f2('0x47')]=_0x32ca19[_0xf5f2('0x47')][_0xf5f2('0x49')]?_0x32ca19[_0xf5f2('0x47')]:_0x51573a[_0xf5f2('0x42')];if(!_0x1afc94[_0xf5f2('0x43')][_0xf5f2('0x4a')](_0xf5f2('0x4b'))){_0x32ca19[_0xf5f2('0x31')]=qs['limit'](_0x1afc94[_0xf5f2('0x43')][_0xf5f2('0x31')]);_0x32ca19[_0xf5f2('0x30')]=qs['offset'](_0x1afc94[_0xf5f2('0x43')][_0xf5f2('0x30')]);}_0x32ca19['order']=qs[_0xf5f2('0x4d')](_0x1afc94['query'][_0xf5f2('0x4d')]);_0x32ca19[_0xf5f2('0x4e')]=qs['filters'](_[_0xf5f2('0x4f')](_0x1afc94['query'],_0x51573a[_0xf5f2('0x45')]));_0x32ca19[_0xf5f2('0x4e')]['FaxAccountId']=_0xb982a1['id'];if(_0x1afc94[_0xf5f2('0x43')][_0xf5f2('0x50')]){_0x32ca19[_0xf5f2('0x4e')]=_[_0xf5f2('0x52')](_0x32ca19[_0xf5f2('0x4e')],{'$or':_['map'](_0x32ca19[_0xf5f2('0x47')],function(_0x391a39){var _0x35284e={};_0x35284e[_0x391a39]={'$like':'%'+_0x1afc94[_0xf5f2('0x43')][_0xf5f2('0x50')]+'%'};return _0x35284e;})});}if(_0x1afc94[_0xf5f2('0x43')][_0xf5f2('0x9e')]){var _0x1d6490=_0x1afc94[_0xf5f2('0x43')]['$gte'][_0xf5f2('0x9f')](',');var _0x5d9e26={};_0x5d9e26[_0x1d6490[0x0]]={'$gte':moment(_0x1d6490[0x1])['format'](_0xf5f2('0xa0'))};_0x32ca19[_0xf5f2('0x4e')]=_[_0xf5f2('0x52')](_0x32ca19[_0xf5f2('0x4e')],_0x5d9e26);}_0x32ca19=_[_0xf5f2('0x52')]({},_0x32ca19,_0x1afc94[_0xf5f2('0x53')]);return db[_0xf5f2('0x9d')][_0xf5f2('0x2f')]({'where':_0x32ca19[_0xf5f2('0x4e')]})[_0xf5f2('0x21')](function(_0x5c2e06){_0x5b96ef['count']=_0x5c2e06;if(_0x1afc94['query'][_0xf5f2('0x54')]){_0x32ca19['include']=[{'all':!![]}];}return db[_0xf5f2('0x9d')][_0xf5f2('0x68')](_0x32ca19);})[_0xf5f2('0x21')](function(_0x5ac7ee){_0x5b96ef[_0xf5f2('0x55')]=_0x5ac7ee;return _0x5b96ef;});}})[_0xf5f2('0x21')](respondWithFilteredResult(_0x33f987,_0x32ca19))['catch'](handleError(_0x33f987,null));};exports['send']=function(_0x4d0709,_0x18cfa9,_0x139a5c){var _0x14ab4d,_0x4f9241={},_0x2cfa84;if(_0x4d0709['body']['to']){_0x2cfa84=_0x4d0709[_0xf5f2('0x60')]['to'][0x0];}return db[_0xf5f2('0x3e')][_0xf5f2('0x59')]({'where':{'id':_0x4d0709['params']['id']},'include':[{'model':db[_0xf5f2('0xa1')],'as':'List','include':[{'model':db[_0xf5f2('0x72')],'as':_0xf5f2('0xa2'),'where':{'fax':_0x2cfa84},'limit':0x1,'order':[[_0xf5f2('0x98'),'DESC']]}]}]})[_0xf5f2('0x21')](handleEntityNotFound(_0x18cfa9,null))[_0xf5f2('0x21')](function(_0x57b4a1){_0x14ab4d=_0x57b4a1;if(_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')]&&_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][_0xf5f2('0x49')]){for(var _0x439c9f=0x0;_0x439c9f<_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][_0xf5f2('0x49')];_0x439c9f+=0x1){_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][_0x439c9f]={'filename':_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][_0x439c9f][_0xf5f2('0x3a')],'id':_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][_0x439c9f]['id'],'path':path[_0xf5f2('0xa4')](config[_0xf5f2('0xa5')],_0xf5f2('0xa6'),_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][_0x439c9f][_0xf5f2('0xa7')])};}}return respondWithRpcPromise('CheckAfterSend',_0xf5f2('0xa8'),{'FaxAccountId':_[_0xf5f2('0xa9')](_0x4d0709[_0xf5f2('0x57')]['id'])?undefined:_0x4d0709[_0xf5f2('0x57')]['id'],'path':_['isNil'](_0x4d0709[_0xf5f2('0x60')]['attachments'][0x0][_0xf5f2('0xaa')])?undefined:_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][0x0][_0xf5f2('0xaa')],'fax':_[_0xf5f2('0xa9')](_0x4d0709[_0xf5f2('0x60')]['to'][0x0])?undefined:_0x4d0709[_0xf5f2('0x60')]['to'][0x0]},client9002);})['then'](function(){if(_0x14ab4d){if(_['isNil'](_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xab')])){_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xab')]=util['format'](_0xf5f2('0xac'),_0x14ab4d[_0xf5f2('0x3a')],_0x14ab4d[_0xf5f2('0xad')]);}if(_0x14ab4d[_0xf5f2('0xae')]){if(_0x14ab4d[_0xf5f2('0xae')][_0xf5f2('0xa2')]['length']){return _0x14ab4d['List']['Contacts'][0x0];}else{return db[_0xf5f2('0x72')][_0xf5f2('0x5a')](_[_0xf5f2('0x19')](_0x4d0709['body'],{'firstName':_0x4d0709[_0xf5f2('0x60')]['to'][0x0],'phone':_0x4d0709['body']['to'][0x0],'fax':_0x4d0709[_0xf5f2('0x60')]['to'][0x0],'ListId':_0x14ab4d[_0xf5f2('0x9a')]}));}}else{throw new Error(_0xf5f2('0xaf'));}}else{throw new Error(_0xf5f2('0xb0'));}})[_0xf5f2('0x21')](function(_0x1556cb){if(_0x1556cb){return db[_0xf5f2('0x6f')][_0xf5f2('0x59')]({'where':{'ContactId':_0x1556cb['id'],'closed':![],'FaxAccountId':_0x14ab4d['id']}})[_0xf5f2('0x21')](function(_0x381759){if(_0x381759){return[_0x381759,![]];}return db[_0xf5f2('0x6f')][_0xf5f2('0x5a')]({'UserId':_0x4d0709[_0xf5f2('0x5b')]['id'],'ContactId':_0x1556cb['id'],'FaxAccountId':_0x14ab4d['id'],'fax':_0x4d0709[_0xf5f2('0x60')]['to'][0x0],'firstMsgDirection':'out','Messages':[_[_0xf5f2('0x52')](_0x4d0709[_0xf5f2('0x60')],{'read':![],'body':_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][0x0]['filename'],'FaxAccountId':_0x14ab4d['id'],'UserId':_0x4d0709[_0xf5f2('0x5b')]['id'],'ContactId':_0x1556cb['id'],'AttachmentId':_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][0x0]['id']})]},{'include':[{'model':db[_0xf5f2('0x9d')],'as':'Messages'}]})[_0xf5f2('0x21')](function(_0x5462ac){return[_0x5462ac,!![]];});});}else{throw new Error(_0xf5f2('0xb1'));}})[_0xf5f2('0xb2')](function(_0x20bb46,_0x17dc52){if(_0x17dc52){return _0x20bb46;}return db['FaxMessage'][_0xf5f2('0x5a')]({'direction':_0xf5f2('0xb3'),'read':![],'body':_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][0x0][_0xf5f2('0xb4')],'FaxAccountId':_0x14ab4d['id'],'FaxInteractionId':_0x20bb46['id'],'UserId':_0x4d0709[_0xf5f2('0x5b')]['id'],'ContactId':_0x20bb46['ContactId'],'AttachmentId':_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][0x0]['id']})[_0xf5f2('0x21')](function(_0x3dcf4e){_0x20bb46[_0xf5f2('0xb5')][_0xf5f2('0xb6')]=[];_0x20bb46[_0xf5f2('0xb5')][_0xf5f2('0xb6')][_0xf5f2('0x88')](_0x3dcf4e['dataValues']);return _0x20bb46;});})[_0xf5f2('0x21')](function(_0x13353f){respondWithRpcPromise(_0xf5f2('0xb7'),_0xf5f2('0xb7'),{'FaxAccountId':_['isNil'](_0x4d0709['params']['id'])?undefined:_0x4d0709[_0xf5f2('0x57')]['id'],'path':_[_0xf5f2('0xa9')](_0x4d0709[_0xf5f2('0x60')]['attachments'][0x0]['path'])?undefined:_0x4d0709[_0xf5f2('0x60')][_0xf5f2('0xa3')][0x0][_0xf5f2('0xaa')],'fax':_[_0xf5f2('0xa9')](_0x4d0709[_0xf5f2('0x60')]['to'][0x0])?undefined:_0x4d0709[_0xf5f2('0x60')]['to'][0x0],'AttachmentId':_0x4d0709['body'][_0xf5f2('0xa3')][0x0]['id']},client9002)[_0xf5f2('0x21')](function(_0x1c18a0){logger[_0xf5f2('0x22')]('SendFaxRpc,\x20%s',_0x1c18a0);})['catch'](function(_0x40f447){logger['info'](_0xf5f2('0xb8'),_0x40f447);});return _0x13353f;})[_0xf5f2('0x21')](respondWithResult(_0x18cfa9,null))[_0xf5f2('0x2a')](handleError(_0x18cfa9,null));};exports[_0xf5f2('0xb9')]=function(_0x45a01e,_0x3d6d4c,_0x40782a){return db[_0xf5f2('0x3e')][_0xf5f2('0x59')]({'where':{'id':_0x45a01e[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x3d6d4c,null))[_0xf5f2('0x21')](function(_0x6734c5){if(_0x6734c5){return _0x6734c5[_0xf5f2('0xb9')](_0x45a01e['body'][_0xf5f2('0x6a')],_[_0xf5f2('0x70')](_0x45a01e[_0xf5f2('0x60')],[_0xf5f2('0x6a'),'id'])||{})[_0xf5f2('0xb2')](function(_0x592ee0){for(var _0x374b5e=0x0;_0x374b5e<_0x45a01e[_0xf5f2('0x60')]['ids'][_0xf5f2('0x49')];_0x374b5e+=0x1){socket[_0xf5f2('0xba')]('userFaxAccount:save',{'UserId':_0x45a01e['body'][_0xf5f2('0x6a')][_0x374b5e],'FaxAccountId':_0x45a01e[_0xf5f2('0x57')]['id']});}return _0x592ee0;});}})[_0xf5f2('0x21')](respondWithResult(_0x3d6d4c,null))['catch'](handleError(_0x3d6d4c,null));};exports['removeAgents']=function(_0x48b359,_0x3e4c88,_0x12fdeb){return db[_0xf5f2('0x3e')][_0xf5f2('0x59')]({'where':{'id':_0x48b359[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x3e4c88,null))[_0xf5f2('0x21')](function(_0x4128ee){if(_0x4128ee){return _0x4128ee[_0xf5f2('0xbb')](_0x48b359['query'][_0xf5f2('0x6a')])[_0xf5f2('0x21')](function(){if(_['isArray'](_0x48b359[_0xf5f2('0x43')][_0xf5f2('0x6a')])){for(var _0xecb4d2=0x0;_0xecb4d2<_0x48b359[_0xf5f2('0x43')][_0xf5f2('0x6a')]['length'];_0xecb4d2+=0x1){socket['emit'](_0xf5f2('0xbc'),{'UserId':Number(_0x48b359[_0xf5f2('0x43')][_0xf5f2('0x6a')][_0xecb4d2]),'FaxAccountId':Number(_0x48b359[_0xf5f2('0x57')]['id'])});}}else{socket['emit'](_0xf5f2('0xbc'),{'UserId':Number(_0x48b359[_0xf5f2('0x43')][_0xf5f2('0x6a')]),'FaxAccountId':Number(_0x48b359[_0xf5f2('0x57')]['id'])});}});}})['then'](respondWithStatusCode(_0x3e4c88,null))['catch'](handleError(_0x3e4c88,null));};exports['getAgents']=function(_0x4e74e0,_0x2e9d3b,_0x496802){var _0x5be074={};var _0x561666={};var _0x4966cf;var _0x16bcfa;return db['FaxAccount']['findOne']({'where':{'id':_0x4e74e0[_0xf5f2('0x57')]['id']}})[_0xf5f2('0x21')](handleEntityNotFound(_0x2e9d3b,null))[_0xf5f2('0x21')](function(_0x327e03){if(_0x327e03){_0x4966cf=_0x327e03;_0x561666['model']=_[_0xf5f2('0x44')](db[_0xf5f2('0xbd')][_0xf5f2('0x3f')]);_0x561666[_0xf5f2('0x43')]=_[_0xf5f2('0x44')](_0x4e74e0[_0xf5f2('0x43')]);_0x561666[_0xf5f2('0x45')]=_['intersection'](_0x561666[_0xf5f2('0x42')],_0x561666[_0xf5f2('0x43')]);_0x5be074['attributes']=_[_0xf5f2('0x46')](_0x561666[_0xf5f2('0x42')],qs[_0xf5f2('0x48')](_0x4e74e0[_0xf5f2('0x43')][_0xf5f2('0x48')]));_0x5be074['attributes']=_0x5be074[_0xf5f2('0x47')]['length']?_0x5be074[_0xf5f2('0x47')]:_0x561666[_0xf5f2('0x42')];_0x5be074[_0xf5f2('0x4c')]=qs[_0xf5f2('0x4d')](_0x4e74e0['query']['sort']);_0x5be074[_0xf5f2('0x4e')]=qs[_0xf5f2('0x45')](_[_0xf5f2('0x4f')](_0x4e74e0[_0xf5f2('0x43')],_0x561666[_0xf5f2('0x45')]));if(_0x4e74e0[_0xf5f2('0x43')][_0xf5f2('0x50')]){_0x5be074[_0xf5f2('0x4e')]=_['merge'](_0x5be074['where'],{'$or':_[_0xf5f2('0x3d')](_0x5be074[_0xf5f2('0x47')],function(_0x5f424e){var _0xb8bcf3={};_0xb8bcf3[_0x5f424e]={'$like':'%'+_0x4e74e0[_0xf5f2('0x43')][_0xf5f2('0x50')]+'%'};return _0xb8bcf3;})});}_0x5be074=_[_0xf5f2('0x52')]({},_0x5be074,_0x4e74e0[_0xf5f2('0x53')]);return _0x4966cf[_0xf5f2('0xbe')](_0x5be074);}})[_0xf5f2('0x21')](function(_0x4702df){if(_0x4702df){_0x16bcfa=_0x4702df[_0xf5f2('0x49')];if(!_0x4e74e0[_0xf5f2('0x43')][_0xf5f2('0x4a')](_0xf5f2('0x4b'))){_0x5be074[_0xf5f2('0x31')]=qs[_0xf5f2('0x31')](_0x4e74e0[_0xf5f2('0x43')][_0xf5f2('0x31')]);_0x5be074[_0xf5f2('0x30')]=qs['offset'](_0x4e74e0[_0xf5f2('0x43')]['offset']);}return _0x4966cf[_0xf5f2('0xbe')](_0x5be074);}})['then'](function(_0x47bc74){if(_0x47bc74){return _0x47bc74?{'count':_0x16bcfa,'rows':_0x47bc74}:null;}})[_0xf5f2('0x21')](respondWithResult(_0x2e9d3b,null))[_0xf5f2('0x2a')](handleError(_0x2e9d3b,null));};
\ No newline at end of file