Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index 6a6605d..4d7b635 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf95f=['../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','jayson/promise','client','http','then','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','FaxAccount,\x20%s,\x20%s','message','result','catch','status','end','json','undefined','count','offset','limit','set','reject','save','update','destroy','get','FaxAccounts','UserProfileResource','stack','name','send','index','Pause','mandatoryDispositionPause','map','FaxAccount','rawAttributes','fieldName','type','key','model','keys','query','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','pick','merge','filter','includeAll','rows','show','params','length','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','autoAssociation','describe','addDisposition','FaxAccountId','Disposition','getDispositions','findOne','options','include','findAll','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','omit','getInteractions','FaxInteraction','CmContact','Contact','User','Owner','fullname','internal','Tags','color','tag','transaction','sequelize','ISOLATION_LEVELS','FaxApplication','bulkCreate','findAndCountAll','finally','sendStatus','getApplications','context','from-voip-provider','exten','localstationid','system','description','priority','appdata','Answer','push','CDR(type)=inbound-fax','ecm','gateway','headerinfo','maxrate','modem','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','ListId','findById','getMessages','FaxMessage','$gte','split','format','CmList','Contacts','DESC','attachments','join','server/files/attachments','basename','CheckAfterSend','isNil','from','\x22%s\x22\x20<%s>','fax','List','List\x20not\x20found','Send\x20Fax\x20failed','out','filename','Contact\x20not\x20found','spread','ContactId','Messages','dataValues','SendFax','info','SendFaxRpc,\x20%s','addAgents','emit','userFaxAccount:save','removeAgents','isArray','userFaxAccount:remove','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware'];(function(_0x53ccf2,_0x13cb67){var _0x5a2964=function(_0x3b0514){while(--_0x3b0514){_0x53ccf2['push'](_0x53ccf2['shift']());}};_0x5a2964(++_0x13cb67);}(_0xf95f,0x16f));var _0xff95=function(_0x49536b,_0x2abe5d){_0x49536b=_0x49536b-0x0;var _0x30de59=_0xf95f[_0x49536b];return _0x30de59;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xff95('0x0'));var zipdir=require(_0xff95('0x1'));var jsonpatch=require(_0xff95('0x2'));var rp=require(_0xff95('0x3'));var moment=require('moment');var BPromise=require(_0xff95('0x4'));var Mustache=require(_0xff95('0x5'));var util=require(_0xff95('0x6'));var path=require(_0xff95('0x7'));var sox=require(_0xff95('0x8'));var csv=require('to-csv');var ejs=require(_0xff95('0x9'));var fs=require('fs');var fs_extra=require(_0xff95('0xa'));var _=require(_0xff95('0xb'));var squel=require('squel');var crypto=require(_0xff95('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xff95('0xd'));var toCsv=require('to-csv');var querystring=require(_0xff95('0xe'));var Papa=require(_0xff95('0xf'));var Redis=require(_0xff95('0x10'));var authService=require(_0xff95('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xff95('0x12'));var logger=require(_0xff95('0x13'))(_0xff95('0x14'));var utils=require('../../config/utils');var config=require(_0xff95('0x15'));var licenseUtil=require(_0xff95('0x16'));var db=require(_0xff95('0x17'))['db'];config[_0xff95('0x18')]=_[_0xff95('0x19')](config[_0xff95('0x18')],{'host':_0xff95('0x1a'),'port':0x18eb});var socket=require(_0xff95('0x1b'))(new Redis(config['redis']));require(_0xff95('0x1c'))['register'](socket);var jayson=require(_0xff95('0x1d'));var client=jayson[_0xff95('0x1e')][_0xff95('0x1f')]({'port':0x232c});var client9002=jayson['client'][_0xff95('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x172062,_0x24a1c0,_0x15ed0f,_0x2c0dfd){return new BPromise(function(_0x240cae,_0x49d490){var _0x5aeba0=_0x2c0dfd||client;return _0x5aeba0['request'](_0x172062,_0x15ed0f)[_0xff95('0x20')](function(_0x523ab2){logger['info']('FaxAccount,\x20%s,\x20%s',_0x24a1c0,_0xff95('0x21'));logger[_0xff95('0x22')](_0xff95('0x23'),_0x24a1c0,_0xff95('0x21'),JSON[_0xff95('0x24')](_0x523ab2));if(_0x523ab2[_0xff95('0x25')]){if(_0x523ab2[_0xff95('0x25')]['code']===0x1f4){logger['error'](_0xff95('0x26'),_0x24a1c0,_0x523ab2['error'][_0xff95('0x27')]);return _0x49d490(_0x523ab2[_0xff95('0x25')][_0xff95('0x27')]);}logger[_0xff95('0x25')]('FaxAccount,\x20%s,\x20%s',_0x24a1c0,_0x523ab2[_0xff95('0x25')][_0xff95('0x27')]);return _0x240cae(_0x523ab2['error'][_0xff95('0x27')]);}else{logger['info']('FaxAccount,\x20%s,\x20%s',_0x24a1c0,_0xff95('0x21'));_0x240cae(_0x523ab2[_0xff95('0x28')]['message']);}})[_0xff95('0x29')](function(_0x24e308){logger['error'](_0xff95('0x26'),_0x24a1c0,_0x24e308);_0x49d490(_0x24e308);});});}function respondWithStatusCode(_0x1d70af,_0x5010c8){_0x5010c8=_0x5010c8||0xcc;return function(_0x2f99fc){if(_0x2f99fc){return _0x1d70af['sendStatus'](_0x5010c8);}return _0x1d70af[_0xff95('0x2a')](_0x5010c8)[_0xff95('0x2b')]();};}function respondWithResult(_0x21749c,_0x2c70c6){_0x2c70c6=_0x2c70c6||0xc8;return function(_0x2ba66a){if(_0x2ba66a){return _0x21749c[_0xff95('0x2a')](_0x2c70c6)[_0xff95('0x2c')](_0x2ba66a);}};}function respondWithFilteredResult(_0x3b4c06,_0x1613d6){return function(_0x28938f){if(_0x28938f){var _0x54e059=typeof _0x1613d6['offset']===_0xff95('0x2d')&&typeof _0x1613d6['limit']===_0xff95('0x2d');var _0x4302ab=_0x28938f[_0xff95('0x2e')];var _0x31aaa6=_0x54e059?0x0:_0x1613d6[_0xff95('0x2f')];var _0x627b6d=_0x54e059?_0x28938f['count']:_0x1613d6['offset']+_0x1613d6[_0xff95('0x30')];var _0x12493f;if(_0x627b6d>=_0x4302ab){_0x627b6d=_0x4302ab;_0x12493f=0xc8;}else{_0x12493f=0xce;}_0x3b4c06[_0xff95('0x2a')](_0x12493f);return _0x3b4c06[_0xff95('0x31')]('Content-Range',_0x31aaa6+'-'+_0x627b6d+'/'+_0x4302ab)[_0xff95('0x2c')](_0x28938f);}return null;};}function patchUpdates(_0x2a7bdd){return function(_0x1b82b4){try{jsonpatch['apply'](_0x1b82b4,_0x2a7bdd,!![]);}catch(_0x575098){return BPromise[_0xff95('0x32')](_0x575098);}return _0x1b82b4[_0xff95('0x33')]();};}function saveUpdates(_0x45527c,_0x58d1d8){return function(_0x1b3a44){if(_0x1b3a44){return _0x1b3a44[_0xff95('0x34')](_0x45527c)[_0xff95('0x20')](function(_0x141895){return _0x141895;});}return null;};}function removeEntity(_0x46a9ed,_0x171f9d){return function(_0xaa7a54){if(_0xaa7a54){return _0xaa7a54[_0xff95('0x35')]()[_0xff95('0x20')](function(){var _0x4ab000=_0xaa7a54[_0xff95('0x36')]({'plain':!![]});var _0x306cd5=_0xff95('0x37');return db[_0xff95('0x38')][_0xff95('0x35')]({'where':{'type':_0x306cd5,'resourceId':_0x4ab000['id']}})[_0xff95('0x20')](function(){return _0xaa7a54;});})[_0xff95('0x20')](function(){_0x46a9ed['status'](0xcc)[_0xff95('0x2b')]();});}};}function handleEntityNotFound(_0x2e0b26,_0x42a82c){return function(_0x4a3a23){if(!_0x4a3a23){_0x2e0b26['sendStatus'](0x194);}return _0x4a3a23;};}function handleError(_0x3c65b8,_0x4dce23){_0x4dce23=_0x4dce23||0x1f4;return function(_0x13ab41){logger[_0xff95('0x25')](_0x13ab41[_0xff95('0x39')]);if(_0x13ab41[_0xff95('0x3a')]){delete _0x13ab41[_0xff95('0x3a')];}_0x3c65b8[_0xff95('0x2a')](_0x4dce23)[_0xff95('0x3b')](_0x13ab41);};}exports[_0xff95('0x3c')]=function(_0x8c75f4,_0x37122c){var _0x56faae={'include':[{'model':db[_0xff95('0x3d')],'as':_0xff95('0x3e')}]},_0x5618a1={},_0x1e5fc4={'count':0x0,'rows':[]};var _0x43f443=_[_0xff95('0x3f')](db[_0xff95('0x40')][_0xff95('0x41')],function(_0x315dde){return{'name':_0x315dde[_0xff95('0x42')],'type':_0x315dde[_0xff95('0x43')][_0xff95('0x44')]};});_0x5618a1[_0xff95('0x45')]=_[_0xff95('0x3f')](_0x43f443,_0xff95('0x3a'));_0x5618a1['query']=_[_0xff95('0x46')](_0x8c75f4[_0xff95('0x47')]);_0x5618a1['filters']=_[_0xff95('0x48')](_0x5618a1[_0xff95('0x45')],_0x5618a1[_0xff95('0x47')]);_0x56faae[_0xff95('0x49')]=_['intersection'](_0x5618a1[_0xff95('0x45')],qs[_0xff95('0x4a')](_0x8c75f4[_0xff95('0x47')][_0xff95('0x4a')]));_0x56faae[_0xff95('0x49')]=_0x56faae['attributes']['length']?_0x56faae[_0xff95('0x49')]:_0x5618a1[_0xff95('0x45')];if(!_0x8c75f4[_0xff95('0x47')][_0xff95('0x4b')](_0xff95('0x4c'))){_0x56faae['limit']=qs[_0xff95('0x30')](_0x8c75f4[_0xff95('0x47')][_0xff95('0x30')]);_0x56faae['offset']=qs[_0xff95('0x2f')](_0x8c75f4[_0xff95('0x47')][_0xff95('0x2f')]);}_0x56faae[_0xff95('0x4d')]=qs[_0xff95('0x4e')](_0x8c75f4[_0xff95('0x47')][_0xff95('0x4e')]);_0x56faae[_0xff95('0x4f')]=qs[_0xff95('0x50')](_[_0xff95('0x51')](_0x8c75f4[_0xff95('0x47')],_0x5618a1[_0xff95('0x50')]),_0x43f443);if(_0x8c75f4[_0xff95('0x47')]['filter']){_0x56faae['where']=_[_0xff95('0x52')](_0x56faae[_0xff95('0x4f')],{'$or':_[_0xff95('0x3f')](_0x43f443,function(_0x45e091){if(_0x45e091['type']!=='VIRTUAL'){var _0x3f0a36={};_0x3f0a36[_0x45e091[_0xff95('0x3a')]]={'$like':'%'+_0x8c75f4[_0xff95('0x47')][_0xff95('0x53')]+'%'};return _0x3f0a36;}})});}_0x56faae=_[_0xff95('0x52')]({},_0x56faae,_0x8c75f4['options']);var _0x2601da={'where':_0x56faae['where']};return db[_0xff95('0x40')][_0xff95('0x2e')](_0x2601da)['then'](function(_0x1d7c87){_0x1e5fc4[_0xff95('0x2e')]=_0x1d7c87;if(_0x8c75f4[_0xff95('0x47')][_0xff95('0x54')]){_0x56faae['include']=[{'all':!![]}];}return db['FaxAccount']['findAll'](_0x56faae);})['then'](function(_0x543c18){_0x1e5fc4[_0xff95('0x55')]=_0x543c18;return _0x1e5fc4;})['then'](respondWithFilteredResult(_0x37122c,_0x56faae))['catch'](handleError(_0x37122c,null));};exports[_0xff95('0x56')]=function(_0x5dabd0,_0x34286d){var _0x18c365={'raw':![],'where':{'id':_0x5dabd0[_0xff95('0x57')]['id']},'include':[{'model':db[_0xff95('0x3d')],'as':_0xff95('0x3e')}]},_0xc31cc0={};_0xc31cc0[_0xff95('0x45')]=_['keys'](db[_0xff95('0x40')]['rawAttributes']);_0xc31cc0['query']=_[_0xff95('0x46')](_0x5dabd0[_0xff95('0x47')]);_0xc31cc0[_0xff95('0x50')]=_[_0xff95('0x48')](_0xc31cc0['model'],_0xc31cc0[_0xff95('0x47')]);_0x18c365[_0xff95('0x49')]=_[_0xff95('0x48')](_0xc31cc0[_0xff95('0x45')],qs['fields'](_0x5dabd0['query'][_0xff95('0x4a')]));_0x18c365[_0xff95('0x49')]=_0x18c365['attributes'][_0xff95('0x58')]?_0x18c365[_0xff95('0x49')]:_0xc31cc0['model'];if(_0x5dabd0[_0xff95('0x47')][_0xff95('0x54')]){_0x18c365['include']=[{'all':!![]}];}_0x18c365=_[_0xff95('0x52')]({},_0x18c365,_0x5dabd0['options']);return db[_0xff95('0x40')]['find'](_0x18c365)['then'](handleEntityNotFound(_0x34286d,null))['then'](respondWithResult(_0x34286d,null))['catch'](handleError(_0x34286d,null));};exports[_0xff95('0x59')]=function(_0x1a00e0,_0x123d90){return db[_0xff95('0x40')][_0xff95('0x59')](_0x1a00e0[_0xff95('0x5a')],{})[_0xff95('0x20')](function(_0x1709e8){var _0x250cfa=_0x1a00e0[_0xff95('0x5b')][_0xff95('0x36')]({'plain':!![]});if(!_0x250cfa)throw new Error(_0xff95('0x5c'));if(_0x250cfa['role']===_0xff95('0x5b')){var _0x3f03d7=_0x1709e8[_0xff95('0x36')]({'plain':!![]});var _0xf74dcd='FaxAccounts';return db[_0xff95('0x5d')][_0xff95('0x5e')]({'where':{'name':_0xf74dcd,'userProfileId':_0x250cfa['userProfileId']},'raw':!![]})[_0xff95('0x20')](function(_0x47fa24){if(_0x47fa24&&_0x47fa24[_0xff95('0x5f')]===0x0){return db[_0xff95('0x38')][_0xff95('0x59')]({'name':_0x3f03d7[_0xff95('0x3a')],'resourceId':_0x3f03d7['id'],'type':_0x47fa24['name'],'sectionId':_0x47fa24['id']},{})[_0xff95('0x20')](function(){return _0x1709e8;});}else{return _0x1709e8;}})[_0xff95('0x29')](function(_0x2e29e3){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2e29e3);throw _0x2e29e3;});}return _0x1709e8;})[_0xff95('0x20')](respondWithResult(_0x123d90,0xc9))['catch'](handleError(_0x123d90,null));};exports[_0xff95('0x34')]=function(_0xd5d027,_0x5e8d74){if(_0xd5d027[_0xff95('0x5a')]['id']){delete _0xd5d027['body']['id'];}return db['FaxAccount'][_0xff95('0x5e')]({'where':{'id':_0xd5d027['params']['id']},'include':[{'model':db[_0xff95('0x3d')],'as':_0xff95('0x3e')}]})[_0xff95('0x20')](handleEntityNotFound(_0x5e8d74,null))[_0xff95('0x20')](saveUpdates(_0xd5d027['body'],null))['then'](respondWithResult(_0x5e8d74,null))[_0xff95('0x29')](handleError(_0x5e8d74,null));};exports[_0xff95('0x35')]=function(_0x1e72f6,_0x504408){return db[_0xff95('0x40')][_0xff95('0x5e')]({'where':{'id':_0x1e72f6[_0xff95('0x57')]['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x504408,null))[_0xff95('0x20')](removeEntity(_0x504408,null))[_0xff95('0x29')](handleError(_0x504408,null));};exports[_0xff95('0x60')]=function(_0x2de52b,_0x40cf5f){return db['FaxAccount'][_0xff95('0x60')]()['then'](respondWithResult(_0x40cf5f,null))[_0xff95('0x29')](handleError(_0x40cf5f,null));};exports[_0xff95('0x61')]=function(_0x3cd996,_0x18131b,_0x1ede1a){if(_0x3cd996[_0xff95('0x5a')]['id']){delete _0x3cd996[_0xff95('0x5a')]['id'];}return db[_0xff95('0x40')][_0xff95('0x5e')]({'where':{'id':_0x3cd996[_0xff95('0x57')]['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x18131b,null))['then'](function(_0x9c419b){if(_0x9c419b){_0x3cd996[_0xff95('0x5a')][_0xff95('0x62')]=_0x9c419b['id'];return db[_0xff95('0x63')][_0xff95('0x59')](_0x3cd996[_0xff95('0x5a')]);}})[_0xff95('0x20')](respondWithResult(_0x18131b,null))[_0xff95('0x29')](handleError(_0x18131b,null));};exports[_0xff95('0x64')]=function(_0x4b7d5f,_0x517334,_0xd068df){var _0x4f4f00={'raw':![],'where':{}};var _0x505f40={};var _0x74fcf6={'count':0x0,'rows':[]};return db[_0xff95('0x40')][_0xff95('0x65')]({'where':{'id':_0x4b7d5f['params']['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x517334,null))[_0xff95('0x20')](function(_0x3e449f){if(_0x3e449f){_0x505f40[_0xff95('0x45')]=_[_0xff95('0x46')](db[_0xff95('0x63')][_0xff95('0x41')]);_0x505f40['query']=_[_0xff95('0x46')](_0x4b7d5f['query']);_0x505f40[_0xff95('0x50')]=_[_0xff95('0x48')](_0x505f40[_0xff95('0x45')],_0x505f40['query']);_0x4f4f00[_0xff95('0x49')]=_['intersection'](_0x505f40[_0xff95('0x45')],qs['fields'](_0x4b7d5f[_0xff95('0x47')][_0xff95('0x4a')]));_0x4f4f00[_0xff95('0x49')]=_0x4f4f00['attributes'][_0xff95('0x58')]?_0x4f4f00[_0xff95('0x49')]:_0x505f40[_0xff95('0x45')];if(!_0x4b7d5f[_0xff95('0x47')]['hasOwnProperty'](_0xff95('0x4c'))){_0x4f4f00[_0xff95('0x30')]=qs[_0xff95('0x30')](_0x4b7d5f[_0xff95('0x47')][_0xff95('0x30')]);_0x4f4f00[_0xff95('0x2f')]=qs[_0xff95('0x2f')](_0x4b7d5f[_0xff95('0x47')][_0xff95('0x2f')]);}_0x4f4f00[_0xff95('0x4d')]=qs['sort'](_0x4b7d5f[_0xff95('0x47')][_0xff95('0x4e')]);_0x4f4f00[_0xff95('0x4f')]=qs[_0xff95('0x50')](_['pick'](_0x4b7d5f[_0xff95('0x47')],_0x505f40[_0xff95('0x50')]));_0x4f4f00[_0xff95('0x4f')][_0xff95('0x62')]=_0x3e449f['id'];if(_0x4b7d5f[_0xff95('0x47')][_0xff95('0x53')]){_0x4f4f00[_0xff95('0x4f')]=_['merge'](_0x4f4f00[_0xff95('0x4f')],{'$or':_['map'](_0x4f4f00[_0xff95('0x49')],function(_0x528ee1){var _0x1d88b7={};_0x1d88b7[_0x528ee1]={'$like':'%'+_0x4b7d5f[_0xff95('0x47')][_0xff95('0x53')]+'%'};return _0x1d88b7;})});}_0x4f4f00=_['merge']({},_0x4f4f00,_0x4b7d5f[_0xff95('0x66')]);return db[_0xff95('0x63')][_0xff95('0x2e')]({'where':_0x4f4f00[_0xff95('0x4f')]})[_0xff95('0x20')](function(_0xc1204d){_0x74fcf6[_0xff95('0x2e')]=_0xc1204d;if(_0x4b7d5f['query'][_0xff95('0x54')]){_0x4f4f00[_0xff95('0x67')]=[{'all':!![]}];}return db['Disposition'][_0xff95('0x68')](_0x4f4f00);})[_0xff95('0x20')](function(_0x4fa67e){_0x74fcf6[_0xff95('0x55')]=_0x4fa67e;return _0x74fcf6;});}})[_0xff95('0x20')](respondWithFilteredResult(_0x517334,_0x4f4f00))['catch'](handleError(_0x517334,null));};exports[_0xff95('0x69')]=function(_0x6815f1,_0x4e6e4b,_0x286acf){return db[_0xff95('0x40')][_0xff95('0x5e')]({'where':{'id':_0x6815f1[_0xff95('0x57')]['id']}})['then'](handleEntityNotFound(_0x4e6e4b,null))[_0xff95('0x20')](function(_0x479d26){if(_0x479d26){return _0x479d26[_0xff95('0x69')](_0x6815f1[_0xff95('0x47')][_0xff95('0x6a')]);}})[_0xff95('0x20')](respondWithStatusCode(_0x4e6e4b,null))[_0xff95('0x29')](handleError(_0x4e6e4b,null));};exports[_0xff95('0x6b')]=function(_0x7b69d7,_0x1d2d78,_0x280508){if(_0x7b69d7[_0xff95('0x5a')]['id']){delete _0x7b69d7[_0xff95('0x5a')]['id'];}return db[_0xff95('0x40')][_0xff95('0x5e')]({'where':{'id':_0x7b69d7[_0xff95('0x57')]['id']}})['then'](handleEntityNotFound(_0x1d2d78,null))[_0xff95('0x20')](function(_0x15cf83){if(_0x15cf83){_0x7b69d7[_0xff95('0x5a')][_0xff95('0x62')]=_0x15cf83['id'];return db[_0xff95('0x6c')][_0xff95('0x59')](_0x7b69d7['body']);}})[_0xff95('0x20')](respondWithResult(_0x1d2d78,null))[_0xff95('0x29')](handleError(_0x1d2d78,null));};exports[_0xff95('0x6d')]=function(_0x3aa31d,_0x4461a2,_0x46946b){var _0x1a2080={'raw':![],'where':{}};var _0x2730e3={};var _0x19e8d2={'count':0x0,'rows':[]};return db[_0xff95('0x40')][_0xff95('0x65')]({'where':{'id':_0x3aa31d[_0xff95('0x57')]['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x4461a2,null))[_0xff95('0x20')](function(_0x16e596){if(_0x16e596){_0x2730e3['model']=_['keys'](db['CannedAnswer'][_0xff95('0x41')]);_0x2730e3['query']=_['keys'](_0x3aa31d[_0xff95('0x47')]);_0x2730e3['filters']=_[_0xff95('0x48')](_0x2730e3[_0xff95('0x45')],_0x2730e3['query']);_0x1a2080[_0xff95('0x49')]=_[_0xff95('0x48')](_0x2730e3[_0xff95('0x45')],qs[_0xff95('0x4a')](_0x3aa31d['query']['fields']));_0x1a2080[_0xff95('0x49')]=_0x1a2080['attributes'][_0xff95('0x58')]?_0x1a2080[_0xff95('0x49')]:_0x2730e3[_0xff95('0x45')];if(!_0x3aa31d[_0xff95('0x47')][_0xff95('0x4b')](_0xff95('0x4c'))){_0x1a2080[_0xff95('0x30')]=qs[_0xff95('0x30')](_0x3aa31d[_0xff95('0x47')][_0xff95('0x30')]);_0x1a2080[_0xff95('0x2f')]=qs[_0xff95('0x2f')](_0x3aa31d[_0xff95('0x47')][_0xff95('0x2f')]);}_0x1a2080[_0xff95('0x4d')]=qs['sort'](_0x3aa31d[_0xff95('0x47')][_0xff95('0x4e')]);_0x1a2080['where']=qs['filters'](_['pick'](_0x3aa31d['query'],_0x2730e3[_0xff95('0x50')]));_0x1a2080[_0xff95('0x4f')][_0xff95('0x62')]=_0x16e596['id'];if(_0x3aa31d[_0xff95('0x47')][_0xff95('0x53')]){_0x1a2080[_0xff95('0x4f')]=_[_0xff95('0x52')](_0x1a2080['where'],{'$or':_[_0xff95('0x3f')](_0x1a2080[_0xff95('0x49')],function(_0x287c31){var _0x3b5d93={};_0x3b5d93[_0x287c31]={'$like':'%'+_0x3aa31d[_0xff95('0x47')][_0xff95('0x53')]+'%'};return _0x3b5d93;})});}_0x1a2080=_[_0xff95('0x52')]({},_0x1a2080,_0x3aa31d[_0xff95('0x66')]);return db[_0xff95('0x6c')]['count']({'where':_0x1a2080[_0xff95('0x4f')]})[_0xff95('0x20')](function(_0x472e5a){_0x19e8d2[_0xff95('0x2e')]=_0x472e5a;if(_0x3aa31d[_0xff95('0x47')][_0xff95('0x54')]){_0x1a2080[_0xff95('0x67')]=[{'all':!![]}];}return db[_0xff95('0x6c')][_0xff95('0x68')](_0x1a2080);})[_0xff95('0x20')](function(_0x2c6804){_0x19e8d2['rows']=_0x2c6804;return _0x19e8d2;});}})[_0xff95('0x20')](respondWithFilteredResult(_0x4461a2,_0x1a2080))[_0xff95('0x29')](handleError(_0x4461a2,null));};exports['removeAnswers']=function(_0x5f012a,_0x1d5de5,_0xbd48dd){return db['FaxAccount']['find']({'where':{'id':_0x5f012a[_0xff95('0x57')]['id']}})['then'](handleEntityNotFound(_0x1d5de5,null))[_0xff95('0x20')](function(_0xd69789){if(_0xd69789){return _0xd69789[_0xff95('0x6e')](_0x5f012a['query'][_0xff95('0x6a')]);}})[_0xff95('0x20')](respondWithStatusCode(_0x1d5de5,null))[_0xff95('0x29')](handleError(_0x1d5de5,null));};exports['addInteraction']=function(_0x11f2b2,_0x554178,_0x1e46e4){return db['FaxInteraction'][_0xff95('0x5e')]({'where':{'id':_0x11f2b2['params']['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x554178,null))[_0xff95('0x20')](function(_0x1cf806){if(_0x1cf806){return _0x1cf806['addInteraction'](_0x11f2b2[_0xff95('0x5a')][_0xff95('0x6a')],_[_0xff95('0x6f')](_0x11f2b2[_0xff95('0x5a')],['ids','id'])||{});}})['then'](respondWithResult(_0x554178,null))[_0xff95('0x29')](handleError(_0x554178,null));};exports[_0xff95('0x70')]=function(_0x16f436,_0x54ada7,_0x2ed68c){var _0x351050={'raw':![],'where':{}};var _0x76b843={};var _0x13f62d={'count':0x0,'rows':[]};return db[_0xff95('0x40')][_0xff95('0x65')]({'where':{'id':_0x16f436[_0xff95('0x57')]['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x54ada7,null))[_0xff95('0x20')](function(_0x215e42){if(_0x215e42){_0x76b843[_0xff95('0x45')]=_[_0xff95('0x46')](db[_0xff95('0x71')][_0xff95('0x41')]);_0x76b843[_0xff95('0x47')]=_[_0xff95('0x46')](_0x16f436['query']);_0x76b843[_0xff95('0x50')]=_[_0xff95('0x48')](_0x76b843[_0xff95('0x45')],_0x76b843[_0xff95('0x47')]);_0x351050[_0xff95('0x49')]=_[_0xff95('0x48')](_0x76b843[_0xff95('0x45')],qs[_0xff95('0x4a')](_0x16f436[_0xff95('0x47')]['fields']));_0x351050['attributes']=_0x351050[_0xff95('0x49')]['length']?_0x351050[_0xff95('0x49')]:_0x76b843[_0xff95('0x45')];if(!_0x16f436[_0xff95('0x47')][_0xff95('0x4b')](_0xff95('0x4c'))){_0x351050['limit']=qs[_0xff95('0x30')](_0x16f436[_0xff95('0x47')][_0xff95('0x30')]);_0x351050['offset']=qs[_0xff95('0x2f')](_0x16f436[_0xff95('0x47')]['offset']);}_0x351050[_0xff95('0x4d')]=qs['sort'](_0x16f436[_0xff95('0x47')]['sort']);_0x351050[_0xff95('0x4f')]=qs[_0xff95('0x50')](_[_0xff95('0x51')](_0x16f436[_0xff95('0x47')],_0x76b843['filters']));_0x351050['where'][_0xff95('0x62')]=_0x215e42['id'];if(_0x16f436['query'][_0xff95('0x53')]){_0x351050['where']=_[_0xff95('0x52')](_0x351050[_0xff95('0x4f')],{'$or':_[_0xff95('0x3f')](_0x351050[_0xff95('0x49')],function(_0x52d0b6){var _0x4053ad={};_0x4053ad[_0x52d0b6]={'$like':'%'+_0x16f436[_0xff95('0x47')][_0xff95('0x53')]+'%'};return _0x4053ad;})});}_0x351050=_['merge']({},_0x351050,_0x16f436[_0xff95('0x66')]);return db['FaxInteraction'][_0xff95('0x2e')]({'where':_0x351050['where']})[_0xff95('0x20')](function(_0x13b768){_0x13f62d[_0xff95('0x2e')]=_0x13b768;if(_0x16f436['query'][_0xff95('0x54')]){_0x351050['include']=[{'model':db[_0xff95('0x72')],'as':_0xff95('0x73'),'required':![]},{'model':db[_0xff95('0x74')],'as':_0xff95('0x75'),'attributes':[_0xff95('0x3a'),_0xff95('0x76'),_0xff95('0x77')],'required':![]},{'model':db['Tag'],'as':_0xff95('0x78'),'attributes':['id',_0xff95('0x3a'),_0xff95('0x79')],'where':_0x16f436['query'][_0xff95('0x7a')]?{'id':_0x16f436['query'][_0xff95('0x7a')]}:undefined,'required':_0x16f436[_0xff95('0x47')][_0xff95('0x7a')]?!![]:![]}];}return db[_0xff95('0x71')]['findAll'](_0x351050);})[_0xff95('0x20')](function(_0x55d285){_0x13f62d[_0xff95('0x55')]=_0x55d285;return _0x13f62d;});}})[_0xff95('0x20')](respondWithFilteredResult(_0x54ada7,_0x351050))[_0xff95('0x29')](handleError(_0x54ada7,null));};exports['addApplications']=function(_0x165376,_0x49048d){var _0x5ebf35=_0x165376[_0xff95('0x57')]['id'];var _0x16c528=_0x165376['body'];var _0x3bb6df=0xc8;var _0x1dd05d=null;return db['sequelize'][_0xff95('0x7b')]({'isolationLevel':db[_0xff95('0x7c')]['Transaction'][_0xff95('0x7d')]['READ_COMMITTED']},function(_0xbc6e68){return db[_0xff95('0x40')][_0xff95('0x65')]({'where':{'id':_0x5ebf35},'transaction':_0xbc6e68})[_0xff95('0x20')](function(_0x1196fb){if(_0x1196fb){return db[_0xff95('0x7e')]['destroy']({'where':{'FaxAccountId':_0x5ebf35},'transaction':_0xbc6e68})[_0xff95('0x20')](function(){var _0x26e142=_[_0xff95('0x3f')](_0x16c528,function(_0x228fed){_0x228fed[_0xff95('0x62')]=_0x5ebf35;return _0x228fed;});return db[_0xff95('0x7e')][_0xff95('0x7f')](_0x26e142,{'transaction':_0xbc6e68});});}else{_0x3bb6df=0x194;_0x1dd05d=[];}});})['then'](function(){if(_0x3bb6df!==0x194){return db['FaxApplication'][_0xff95('0x80')]({'where':{'FaxAccountId':_0x5ebf35},'order':'priority'})['then'](function(_0x3258d2){_0x1dd05d=_0x3258d2;});}})['catch'](function(_0x23ad7f){_0x3bb6df=0x1f4;logger[_0xff95('0x25')](_0x23ad7f[_0xff95('0x39')]);if(_0x23ad7f[_0xff95('0x3a')]){delete _0x23ad7f[_0xff95('0x3a')];}_0x1dd05d=_0x23ad7f;})[_0xff95('0x81')](function(){if(_0x1dd05d===null){_0x49048d[_0xff95('0x82')](_0x3bb6df);}else{if(_0x3bb6df===0x1f4){_0x49048d['status'](_0x3bb6df)['send'](_0x1dd05d);}else{_0x49048d[_0xff95('0x2a')](_0x3bb6df)[_0xff95('0x2c')](_0x1dd05d);}}});};exports[_0xff95('0x83')]=function(_0x5d0805,_0x5958db,_0x1e0c92){var _0x379276={};var _0x5dea3b={};var _0x2a7e78;var _0x91640d;return db[_0xff95('0x40')]['findOne']({'where':{'id':_0x5d0805[_0xff95('0x57')]['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x5958db,null))[_0xff95('0x20')](function(_0x816ccb){if(_0x816ccb){_0x2a7e78=_0x816ccb;_0x5dea3b['model']=_['keys'](db[_0xff95('0x7e')][_0xff95('0x41')]);_0x5dea3b[_0xff95('0x47')]=_['keys'](_0x5d0805[_0xff95('0x47')]);_0x5dea3b[_0xff95('0x50')]=_[_0xff95('0x48')](_0x5dea3b[_0xff95('0x45')],_0x5dea3b['query']);_0x379276['attributes']=_[_0xff95('0x48')](_0x5dea3b[_0xff95('0x45')],qs[_0xff95('0x4a')](_0x5d0805[_0xff95('0x47')]['fields']));_0x379276[_0xff95('0x49')]=_0x379276[_0xff95('0x49')][_0xff95('0x58')]?_0x379276[_0xff95('0x49')]:_0x5dea3b[_0xff95('0x45')];_0x379276[_0xff95('0x4d')]=qs[_0xff95('0x4e')](_0x5d0805[_0xff95('0x47')][_0xff95('0x4e')]);_0x379276[_0xff95('0x4f')]=qs[_0xff95('0x50')](_[_0xff95('0x51')](_0x5d0805[_0xff95('0x47')],_0x5dea3b[_0xff95('0x50')]));if(_0x5d0805[_0xff95('0x47')][_0xff95('0x53')]){_0x379276[_0xff95('0x4f')]=_[_0xff95('0x52')](_0x379276[_0xff95('0x4f')],{'$or':_['map'](_0x379276[_0xff95('0x49')],function(_0x2a4a84){var _0x3b75bf={};_0x3b75bf[_0x2a4a84]={'$like':'%'+_0x5d0805[_0xff95('0x47')][_0xff95('0x53')]+'%'};return _0x3b75bf;})});}_0x379276=_[_0xff95('0x52')]({},_0x379276,_0x5d0805[_0xff95('0x66')]);return _0x2a7e78['getApplications'](_0x379276);}})[_0xff95('0x20')](function(_0x85123a){if(_0x85123a){_0x91640d=_0x85123a[_0xff95('0x58')];if(!_0x5d0805[_0xff95('0x47')][_0xff95('0x4b')](_0xff95('0x4c'))){_0x379276[_0xff95('0x30')]=qs[_0xff95('0x30')](_0x5d0805[_0xff95('0x47')]['limit']);_0x379276[_0xff95('0x2f')]=qs[_0xff95('0x2f')](_0x5d0805[_0xff95('0x47')]['offset']);}return _0x2a7e78['getApplications'](_0x379276);}})[_0xff95('0x20')](function(_0x5db45e){if(_0x5db45e){return _0x5db45e?{'count':_0x91640d,'rows':_0x5db45e}:null;}})[_0xff95('0x20')](respondWithResult(_0x5958db,null))[_0xff95('0x29')](handleError(_0x5958db,null));};function Extension(_0x5ee563,_0x378c02,_0x3e2f5c,_0x3c6d3a){this[_0xff95('0x84')]=_0xff95('0x85');this[_0xff95('0x86')]=_0x5ee563[_0xff95('0x87')];this['app']=_0x3c6d3a;this[_0xff95('0x43')]=_0xff95('0x88');this[_0xff95('0x89')]='Fax\x20Extension';this[_0xff95('0x62')]=_0x5ee563['id'];this[_0xff95('0x8a')]=_0x378c02;this[_0xff95('0x8b')]=_0x3e2f5c;}function createExtensionsReciveFax(_0x5dca3f){var _0x2fcb7a=0x1;var _0x462105=[];_0x462105['push'](new Extension(_0x5dca3f,_0x2fcb7a,'',_0xff95('0x8c')));_0x2fcb7a+=0x1;_0x462105[_0xff95('0x8d')](new Extension(_0x5dca3f,_0x2fcb7a,_0xff95('0x8e'),'Set'));_0x2fcb7a+=0x1;for(var _0x4667b6 in _0x5dca3f){if(_0x5dca3f['hasOwnProperty'](_0x4667b6)&&(_0x4667b6===_0xff95('0x8f')||_0x4667b6===_0xff95('0x87')||_0x4667b6===_0xff95('0x90')||_0x4667b6==='faxdetect'||_0x4667b6===_0xff95('0x91')||_0x4667b6===_0xff95('0x92')||_0x4667b6==='minrate'||_0x4667b6===_0xff95('0x93')||_0x4667b6==='t38timeout')){_0x462105[_0xff95('0x8d')](new Extension(_0x5dca3f,_0x2fcb7a,'FAXOPT('+_0x4667b6+')='+_0x5dca3f[_0x4667b6],'Set'));_0x2fcb7a+=0x1;}}_0x462105[_0xff95('0x8d')](new Extension(_0x5dca3f,_0x2fcb7a,'6',_0xff95('0x94')));_0x2fcb7a+=0x1;_0x462105['push'](new Extension(_0x5dca3f,_0x2fcb7a,_0xff95('0x95'),_0xff95('0x96')));_0x2fcb7a=0x0;return _0x462105;}exports[_0xff95('0x97')]=function(_0x3b25d2,_0x26b1ac,_0x51b413){var _0xab3042;return db[_0xff95('0x7c')][_0xff95('0x7b')](function(_0x1e0e0e){return db[_0xff95('0x40')]['create'](_0x3b25d2[_0xff95('0x5a')],{'transaction':_0x1e0e0e})[_0xff95('0x20')](function(_0x4680b2){_0xab3042=_0x4680b2['get']({'plain':!![]});return db[_0xff95('0x98')][_0xff95('0x7f')](createExtensionsReciveFax(_0xab3042),{'transaction':_0x1e0e0e});});})[_0xff95('0x20')](function(){return _0xab3042;})[_0xff95('0x20')](respondWithResult(_0x26b1ac,null))[_0xff95('0x29')](handleError(_0x26b1ac,null));};exports[_0xff95('0x99')]=function(_0x55e3b0,_0x4c7d7c,_0x2bc368){var _0x2d3c94;return db[_0xff95('0x7c')]['transaction'](function(_0x152539){return db[_0xff95('0x40')]['update'](_0x55e3b0[_0xff95('0x5a')],{'where':{'id':_0x55e3b0[_0xff95('0x5a')]['id']},'transaction':_0x152539})[_0xff95('0x20')](function(_0x278812){return db['VoiceExtension'][_0xff95('0x35')]({'where':{'FaxAccountId':_0x55e3b0[_0xff95('0x5a')]['id']},'transaction':_0x152539})['then'](function(_0x561e24){return db[_0xff95('0x98')][_0xff95('0x7f')](createExtensionsReciveFax(_[_0xff95('0x6f')](_0x55e3b0[_0xff95('0x5a')],['tech',_0xff95('0x44'),'createdAt','updatedAt','TrunkId',_0xff95('0x9a')])),{'transaction':_0x152539});});});})['then'](function(){return db['FaxAccount'][_0xff95('0x9b')](_0x55e3b0[_0xff95('0x5a')]['id']);})[_0xff95('0x20')](respondWithResult(_0x4c7d7c,null))['catch'](handleError(_0x4c7d7c,null));};exports[_0xff95('0x9c')]=function(_0x4f99b1,_0x3aff8e,_0x5b1a9){var _0x437f39={'raw':!![],'where':{}};var _0x182ab6={};var _0x4f1606={'count':0x0,'rows':[]};return db[_0xff95('0x40')][_0xff95('0x65')]({'where':{'id':_0x4f99b1['params']['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x3aff8e,null))[_0xff95('0x20')](function(_0x50e721){if(_0x50e721){_0x182ab6['model']=_['keys'](db[_0xff95('0x9d')]['rawAttributes']);_0x182ab6['query']=_['keys'](_0x4f99b1['query']);_0x182ab6[_0xff95('0x50')]=_[_0xff95('0x48')](_0x182ab6[_0xff95('0x45')],_0x182ab6[_0xff95('0x47')]);_0x437f39[_0xff95('0x49')]=_['intersection'](_0x182ab6[_0xff95('0x45')],qs[_0xff95('0x4a')](_0x4f99b1[_0xff95('0x47')][_0xff95('0x4a')]));_0x437f39['attributes']=_0x437f39[_0xff95('0x49')]['length']?_0x437f39['attributes']:_0x182ab6[_0xff95('0x45')];if(!_0x4f99b1[_0xff95('0x47')]['hasOwnProperty'](_0xff95('0x4c'))){_0x437f39[_0xff95('0x30')]=qs[_0xff95('0x30')](_0x4f99b1[_0xff95('0x47')]['limit']);_0x437f39['offset']=qs['offset'](_0x4f99b1['query']['offset']);}_0x437f39['order']=qs[_0xff95('0x4e')](_0x4f99b1['query'][_0xff95('0x4e')]);_0x437f39[_0xff95('0x4f')]=qs['filters'](_[_0xff95('0x51')](_0x4f99b1[_0xff95('0x47')],_0x182ab6[_0xff95('0x50')]));_0x437f39[_0xff95('0x4f')]['FaxAccountId']=_0x50e721['id'];if(_0x4f99b1[_0xff95('0x47')]['filter']){_0x437f39[_0xff95('0x4f')]=_[_0xff95('0x52')](_0x437f39[_0xff95('0x4f')],{'$or':_[_0xff95('0x3f')](_0x437f39[_0xff95('0x49')],function(_0x3c417d){var _0x3930cf={};_0x3930cf[_0x3c417d]={'$like':'%'+_0x4f99b1[_0xff95('0x47')][_0xff95('0x53')]+'%'};return _0x3930cf;})});}if(_0x4f99b1[_0xff95('0x47')][_0xff95('0x9e')]){var _0x32332a=_0x4f99b1[_0xff95('0x47')][_0xff95('0x9e')][_0xff95('0x9f')](',');var _0x3ee6ed={};_0x3ee6ed[_0x32332a[0x0]]={'$gte':moment(_0x32332a[0x1])[_0xff95('0xa0')]('YYYY-MM-DD\x20HH:mm:ss')};_0x437f39[_0xff95('0x4f')]=_[_0xff95('0x52')](_0x437f39[_0xff95('0x4f')],_0x3ee6ed);}_0x437f39=_[_0xff95('0x52')]({},_0x437f39,_0x4f99b1[_0xff95('0x66')]);return db['FaxMessage'][_0xff95('0x2e')]({'where':_0x437f39[_0xff95('0x4f')]})[_0xff95('0x20')](function(_0x1ee34c){_0x4f1606[_0xff95('0x2e')]=_0x1ee34c;if(_0x4f99b1[_0xff95('0x47')][_0xff95('0x54')]){_0x437f39[_0xff95('0x67')]=[{'all':!![]}];}return db[_0xff95('0x9d')]['findAll'](_0x437f39);})[_0xff95('0x20')](function(_0x5f57a7){_0x4f1606[_0xff95('0x55')]=_0x5f57a7;return _0x4f1606;});}})[_0xff95('0x20')](respondWithFilteredResult(_0x3aff8e,_0x437f39))[_0xff95('0x29')](handleError(_0x3aff8e,null));};exports[_0xff95('0x3b')]=function(_0x5b9100,_0x20ef22,_0x381787){var _0x551b38,_0x109c6a={},_0x5b5bd9;if(_0x5b9100[_0xff95('0x5a')]['to']){_0x5b5bd9=_0x5b9100[_0xff95('0x5a')]['to'][0x0];}return db[_0xff95('0x40')][_0xff95('0x5e')]({'where':{'id':_0x5b9100[_0xff95('0x57')]['id']},'include':[{'model':db[_0xff95('0xa1')],'as':'List','include':[{'model':db[_0xff95('0x72')],'as':_0xff95('0xa2'),'where':{'fax':_0x5b5bd9},'limit':0x1,'order':[['updatedAt',_0xff95('0xa3')]]}]}]})[_0xff95('0x20')](handleEntityNotFound(_0x20ef22,null))[_0xff95('0x20')](function(_0x33eca0){_0x551b38=_0x33eca0;if(_0x5b9100[_0xff95('0x5a')][_0xff95('0xa4')]&&_0x5b9100[_0xff95('0x5a')]['attachments'][_0xff95('0x58')]){for(var _0x3fda44=0x0;_0x3fda44<_0x5b9100[_0xff95('0x5a')][_0xff95('0xa4')][_0xff95('0x58')];_0x3fda44+=0x1){_0x5b9100[_0xff95('0x5a')]['attachments'][_0x3fda44]={'filename':_0x5b9100[_0xff95('0x5a')][_0xff95('0xa4')][_0x3fda44][_0xff95('0x3a')],'id':_0x5b9100[_0xff95('0x5a')][_0xff95('0xa4')][_0x3fda44]['id'],'path':path[_0xff95('0xa5')](config['root'],_0xff95('0xa6'),_0x5b9100['body']['attachments'][_0x3fda44][_0xff95('0xa7')])};}}return respondWithRpcPromise('CheckAfterSend',_0xff95('0xa8'),{'FaxAccountId':_[_0xff95('0xa9')](_0x5b9100[_0xff95('0x57')]['id'])?undefined:_0x5b9100[_0xff95('0x57')]['id'],'path':_['isNil'](_0x5b9100[_0xff95('0x5a')]['attachments'][0x0][_0xff95('0x7')])?undefined:_0x5b9100['body'][_0xff95('0xa4')][0x0][_0xff95('0x7')],'fax':_[_0xff95('0xa9')](_0x5b9100[_0xff95('0x5a')]['to'][0x0])?undefined:_0x5b9100[_0xff95('0x5a')]['to'][0x0]},client9002);})[_0xff95('0x20')](function(){if(_0x551b38){if(_[_0xff95('0xa9')](_0x5b9100[_0xff95('0x5a')]['from'])){_0x5b9100[_0xff95('0x5a')][_0xff95('0xaa')]=util[_0xff95('0xa0')](_0xff95('0xab'),_0x551b38[_0xff95('0x3a')],_0x551b38[_0xff95('0xac')]);}if(_0x551b38[_0xff95('0xad')]){if(_0x551b38[_0xff95('0xad')][_0xff95('0xa2')][_0xff95('0x58')]){return _0x551b38[_0xff95('0xad')][_0xff95('0xa2')][0x0];}else{return db[_0xff95('0x72')][_0xff95('0x59')](_['defaults'](_0x5b9100[_0xff95('0x5a')],{'firstName':_0x5b9100['body']['to'][0x0],'phone':_0x5b9100['body']['to'][0x0],'fax':_0x5b9100[_0xff95('0x5a')]['to'][0x0],'ListId':_0x551b38['ListId']}));}}else{throw new Error(_0xff95('0xae'));}}else{throw new Error(_0xff95('0xaf'));}})[_0xff95('0x20')](function(_0x30899e){if(_0x30899e){return db['FaxInteraction'][_0xff95('0x5e')]({'where':{'ContactId':_0x30899e['id'],'closed':![],'FaxAccountId':_0x551b38['id']}})['then'](function(_0x30cb1a){if(_0x30cb1a){return[_0x30cb1a,![]];}return db[_0xff95('0x71')][_0xff95('0x59')]({'UserId':_0x5b9100[_0xff95('0x5b')]['id'],'ContactId':_0x30899e['id'],'FaxAccountId':_0x551b38['id'],'fax':_0x5b9100[_0xff95('0x5a')]['to'][0x0],'firstMsgDirection':_0xff95('0xb0'),'Messages':[_[_0xff95('0x52')](_0x5b9100[_0xff95('0x5a')],{'read':![],'body':_0x5b9100[_0xff95('0x5a')][_0xff95('0xa4')][0x0][_0xff95('0xb1')],'FaxAccountId':_0x551b38['id'],'UserId':_0x5b9100[_0xff95('0x5b')]['id'],'ContactId':_0x30899e['id'],'AttachmentId':_0x5b9100[_0xff95('0x5a')][_0xff95('0xa4')][0x0]['id']})]},{'include':[{'model':db[_0xff95('0x9d')],'as':'Messages'}]})[_0xff95('0x20')](function(_0x2ae9b2){return[_0x2ae9b2,!![]];});});}else{throw new Error(_0xff95('0xb2'));}})[_0xff95('0xb3')](function(_0x47bee9,_0x41f08b){if(_0x41f08b){return _0x47bee9;}return db[_0xff95('0x9d')][_0xff95('0x59')]({'direction':_0xff95('0xb0'),'read':![],'body':_0x5b9100[_0xff95('0x5a')]['attachments'][0x0][_0xff95('0xb1')],'FaxAccountId':_0x551b38['id'],'FaxInteractionId':_0x47bee9['id'],'UserId':_0x5b9100[_0xff95('0x5b')]['id'],'ContactId':_0x47bee9[_0xff95('0xb4')],'AttachmentId':_0x5b9100['body'][_0xff95('0xa4')][0x0]['id']})[_0xff95('0x20')](function(_0x3f19e9){_0x47bee9['dataValues'][_0xff95('0xb5')]=[];_0x47bee9[_0xff95('0xb6')][_0xff95('0xb5')][_0xff95('0x8d')](_0x3f19e9[_0xff95('0xb6')]);return _0x47bee9;});})[_0xff95('0x20')](function(_0x3f9abf){respondWithRpcPromise(_0xff95('0xb7'),_0xff95('0xb7'),{'FaxAccountId':_[_0xff95('0xa9')](_0x5b9100['params']['id'])?undefined:_0x5b9100[_0xff95('0x57')]['id'],'path':_[_0xff95('0xa9')](_0x5b9100[_0xff95('0x5a')]['attachments'][0x0][_0xff95('0x7')])?undefined:_0x5b9100[_0xff95('0x5a')][_0xff95('0xa4')][0x0][_0xff95('0x7')],'fax':_[_0xff95('0xa9')](_0x5b9100[_0xff95('0x5a')]['to'][0x0])?undefined:_0x5b9100[_0xff95('0x5a')]['to'][0x0],'AttachmentId':_0x5b9100[_0xff95('0x5a')]['attachments'][0x0]['id']},client9002)['then'](function(_0x3c528d){logger[_0xff95('0xb8')]('SendFaxRpc,\x20%s',_0x3c528d);})[_0xff95('0x29')](function(_0xa4692b){logger[_0xff95('0xb8')](_0xff95('0xb9'),_0xa4692b);});return _0x3f9abf;})[_0xff95('0x20')](respondWithResult(_0x20ef22,null))[_0xff95('0x29')](handleError(_0x20ef22,null));};exports[_0xff95('0xba')]=function(_0x645f94,_0x1d201f,_0x42e38a){return db[_0xff95('0x40')][_0xff95('0x5e')]({'where':{'id':_0x645f94['params']['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x1d201f,null))[_0xff95('0x20')](function(_0x2ce50b){if(_0x2ce50b){return _0x2ce50b[_0xff95('0xba')](_0x645f94[_0xff95('0x5a')][_0xff95('0x6a')],_[_0xff95('0x6f')](_0x645f94[_0xff95('0x5a')],[_0xff95('0x6a'),'id'])||{})[_0xff95('0xb3')](function(_0x5bcd05){for(var _0x3ba6d1=0x0;_0x3ba6d1<_0x645f94[_0xff95('0x5a')][_0xff95('0x6a')][_0xff95('0x58')];_0x3ba6d1+=0x1){socket[_0xff95('0xbb')](_0xff95('0xbc'),{'UserId':Number(_0x645f94['body'][_0xff95('0x6a')][_0x3ba6d1]),'FaxAccountId':Number(_0x645f94[_0xff95('0x57')]['id'])});}return _0x5bcd05;});}})['then'](respondWithResult(_0x1d201f,null))[_0xff95('0x29')](handleError(_0x1d201f,null));};exports['removeAgents']=function(_0x2c1e18,_0x1e5c97,_0x3e5852){return db[_0xff95('0x40')][_0xff95('0x5e')]({'where':{'id':_0x2c1e18['params']['id']}})[_0xff95('0x20')](handleEntityNotFound(_0x1e5c97,null))['then'](function(_0x441db4){if(_0x441db4){return _0x441db4[_0xff95('0xbd')](_0x2c1e18[_0xff95('0x47')][_0xff95('0x6a')])[_0xff95('0x20')](function(){if(_[_0xff95('0xbe')](_0x2c1e18[_0xff95('0x47')][_0xff95('0x6a')])){for(var _0x3a4923=0x0;_0x3a4923<_0x2c1e18['query'][_0xff95('0x6a')][_0xff95('0x58')];_0x3a4923+=0x1){socket[_0xff95('0xbb')](_0xff95('0xbf'),{'UserId':Number(_0x2c1e18[_0xff95('0x47')][_0xff95('0x6a')][_0x3a4923]),'FaxAccountId':Number(_0x2c1e18[_0xff95('0x57')]['id'])});}}else{socket['emit'](_0xff95('0xbf'),{'UserId':Number(_0x2c1e18[_0xff95('0x47')][_0xff95('0x6a')]),'FaxAccountId':Number(_0x2c1e18['params']['id'])});}});}})[_0xff95('0x20')](respondWithStatusCode(_0x1e5c97,null))[_0xff95('0x29')](handleError(_0x1e5c97,null));};exports[_0xff95('0xc0')]=function(_0x4ea067,_0x3f5621,_0x452b39){var _0x443718={};var _0x211b4e={};var _0x37959a;var _0x1178f1;return db['FaxAccount']['findOne']({'where':{'id':_0x4ea067[_0xff95('0x57')]['id']}})['then'](handleEntityNotFound(_0x3f5621,null))[_0xff95('0x20')](function(_0x27e445){if(_0x27e445){_0x37959a=_0x27e445;_0x211b4e[_0xff95('0x45')]=_['keys'](db[_0xff95('0x74')][_0xff95('0x41')]);_0x211b4e[_0xff95('0x47')]=_[_0xff95('0x46')](_0x4ea067[_0xff95('0x47')]);_0x211b4e[_0xff95('0x50')]=_[_0xff95('0x48')](_0x211b4e[_0xff95('0x45')],_0x211b4e[_0xff95('0x47')]);_0x443718[_0xff95('0x49')]=_['intersection'](_0x211b4e[_0xff95('0x45')],qs['fields'](_0x4ea067[_0xff95('0x47')][_0xff95('0x4a')]));_0x443718[_0xff95('0x49')]=_0x443718[_0xff95('0x49')][_0xff95('0x58')]?_0x443718['attributes']:_0x211b4e[_0xff95('0x45')];_0x443718['order']=qs[_0xff95('0x4e')](_0x4ea067['query'][_0xff95('0x4e')]);_0x443718[_0xff95('0x4f')]=qs[_0xff95('0x50')](_[_0xff95('0x51')](_0x4ea067[_0xff95('0x47')],_0x211b4e['filters']));if(_0x4ea067[_0xff95('0x47')][_0xff95('0x53')]){_0x443718[_0xff95('0x4f')]=_[_0xff95('0x52')](_0x443718[_0xff95('0x4f')],{'$or':_[_0xff95('0x3f')](_0x443718[_0xff95('0x49')],function(_0xf4a34){var _0x4d16e1={};_0x4d16e1[_0xf4a34]={'$like':'%'+_0x4ea067[_0xff95('0x47')][_0xff95('0x53')]+'%'};return _0x4d16e1;})});}_0x443718=_['merge']({},_0x443718,_0x4ea067[_0xff95('0x66')]);return _0x37959a['getAgents'](_0x443718);}})['then'](function(_0x1b7c72){if(_0x1b7c72){_0x1178f1=_0x1b7c72[_0xff95('0x58')];if(!_0x4ea067[_0xff95('0x47')][_0xff95('0x4b')](_0xff95('0x4c'))){_0x443718[_0xff95('0x30')]=qs[_0xff95('0x30')](_0x4ea067['query'][_0xff95('0x30')]);_0x443718[_0xff95('0x2f')]=qs[_0xff95('0x2f')](_0x4ea067[_0xff95('0x47')][_0xff95('0x2f')]);}return _0x37959a['getAgents'](_0x443718);}})[_0xff95('0x20')](function(_0x345d90){if(_0x345d90){return _0x345d90?{'count':_0x1178f1,'rows':_0x345d90}:null;}})[_0xff95('0x20')](respondWithResult(_0x3f5621,null))[_0xff95('0x29')](handleError(_0x3f5621,null));};
\ No newline at end of file
+var _0x14c4=['VIRTUAL','FaxAccount','includeAll','include','findAll','catch','show','params','Pause','rawAttributes','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','FaxAccounts','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','FaxAccountId','getDispositions','findOne','Disposition','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','filter','rows','removeAnswers','addInteraction','omit','getInteractions','FaxInteraction','CmContact','Contact','User','fullname','Tag','Tags','color','tag','addApplications','sequelize','transaction','Transaction','ISOLATION_LEVELS','FaxApplication','bulkCreate','findAndCountAll','getApplications','context','from-voip-provider','exten','localstationid','system','description','Fax\x20Extension','priority','push','CDR(type)=inbound-fax','Set','ecm','gateway','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','VoiceExtension','updateAccountApplications','tech','createdAt','updatedAt','TrunkId','ListId','findById','getMessages','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','FaxMessage','CmList','List','DESC','attachments','join','root','server/files/attachments','basename','CheckAfterSend','isNil','from','\x22%s\x22\x20<%s>','fax','Contacts','List\x20not\x20found','Send\x20Fax\x20failed','out','filename','Messages','Contact\x20not\x20found','ContactId','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','emit','removeAgents','isArray','userFaxAccount:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','jayson/promise','http','client','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','get','UserProfileResource','sendStatus','stack','name','send','index','mandatoryDispositionPause','map','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge'];(function(_0x139a3c,_0x4fc883){var _0x2b375b=function(_0x525dbf){while(--_0x525dbf){_0x139a3c['push'](_0x139a3c['shift']());}};_0x2b375b(++_0x4fc883);}(_0x14c4,0x142));var _0x414c=function(_0xea1570,_0x2f7856){_0xea1570=_0xea1570-0x0;var _0x579e74=_0x14c4[_0xea1570];return _0x579e74;};'use strict';var emlformat=require(_0x414c('0x0'));var rimraf=require(_0x414c('0x1'));var zipdir=require(_0x414c('0x2'));var jsonpatch=require(_0x414c('0x3'));var rp=require(_0x414c('0x4'));var moment=require('moment');var BPromise=require(_0x414c('0x5'));var Mustache=require(_0x414c('0x6'));var util=require(_0x414c('0x7'));var path=require(_0x414c('0x8'));var sox=require(_0x414c('0x9'));var csv=require(_0x414c('0xa'));var ejs=require(_0x414c('0xb'));var fs=require('fs');var fs_extra=require(_0x414c('0xc'));var _=require(_0x414c('0xd'));var squel=require(_0x414c('0xe'));var crypto=require(_0x414c('0xf'));var jsforce=require(_0x414c('0x10'));var deskjs=require(_0x414c('0x11'));var toCsv=require(_0x414c('0xa'));var querystring=require('querystring');var Papa=require(_0x414c('0x12'));var Redis=require('ioredis');var authService=require(_0x414c('0x13'));var qs=require(_0x414c('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x414c('0x15'))(_0x414c('0x16'));var utils=require(_0x414c('0x17'));var config=require(_0x414c('0x18'));var licenseUtil=require(_0x414c('0x19'));var db=require(_0x414c('0x1a'))['db'];config[_0x414c('0x1b')]=_[_0x414c('0x1c')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x414c('0x1b')]));require('./faxAccount.socket')['register'](socket);var jayson=require(_0x414c('0x1d'));var client=jayson['client'][_0x414c('0x1e')]({'port':0x232c});var client9002=jayson[_0x414c('0x1f')][_0x414c('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x43ab29,_0xde3f34,_0x3c4787,_0x4f0bb9){return new BPromise(function(_0x1c1e78,_0x52dffe){var _0x112fff=_0x4f0bb9||client;return _0x112fff[_0x414c('0x20')](_0x43ab29,_0x3c4787)[_0x414c('0x21')](function(_0xda4765){logger[_0x414c('0x22')](_0x414c('0x23'),_0xde3f34,_0x414c('0x24'));logger['debug']('FaxAccount,\x20%s,\x20%s,\x20%s',_0xde3f34,_0x414c('0x24'),JSON[_0x414c('0x25')](_0xda4765));if(_0xda4765[_0x414c('0x26')]){if(_0xda4765[_0x414c('0x26')][_0x414c('0x27')]===0x1f4){logger['error'](_0x414c('0x23'),_0xde3f34,_0xda4765['error'][_0x414c('0x28')]);return _0x52dffe(_0xda4765[_0x414c('0x26')][_0x414c('0x28')]);}logger[_0x414c('0x26')](_0x414c('0x23'),_0xde3f34,_0xda4765[_0x414c('0x26')][_0x414c('0x28')]);return _0x1c1e78(_0xda4765['error'][_0x414c('0x28')]);}else{logger['info']('FaxAccount,\x20%s,\x20%s',_0xde3f34,_0x414c('0x24'));_0x1c1e78(_0xda4765[_0x414c('0x29')][_0x414c('0x28')]);}})['catch'](function(_0x2c3442){logger[_0x414c('0x26')](_0x414c('0x23'),_0xde3f34,_0x2c3442);_0x52dffe(_0x2c3442);});});}function respondWithStatusCode(_0x1c961e,_0x31346d){_0x31346d=_0x31346d||0xcc;return function(_0x4ac95f){if(_0x4ac95f){return _0x1c961e['sendStatus'](_0x31346d);}return _0x1c961e[_0x414c('0x2a')](_0x31346d)[_0x414c('0x2b')]();};}function respondWithResult(_0x510e8d,_0x57fd8c){_0x57fd8c=_0x57fd8c||0xc8;return function(_0x5f2630){if(_0x5f2630){return _0x510e8d[_0x414c('0x2a')](_0x57fd8c)[_0x414c('0x2c')](_0x5f2630);}};}function respondWithFilteredResult(_0x107533,_0x2db081){return function(_0x27d542){if(_0x27d542){var _0x21fb3b=typeof _0x2db081[_0x414c('0x2d')]===_0x414c('0x2e')&&typeof _0x2db081[_0x414c('0x2f')]===_0x414c('0x2e');var _0x33484e=_0x27d542[_0x414c('0x30')];var _0x3f10d3=_0x21fb3b?0x0:_0x2db081[_0x414c('0x2d')];var _0x58daed=_0x21fb3b?_0x27d542['count']:_0x2db081['offset']+_0x2db081['limit'];var _0x1af681;if(_0x58daed>=_0x33484e){_0x58daed=_0x33484e;_0x1af681=0xc8;}else{_0x1af681=0xce;}_0x107533['status'](_0x1af681);return _0x107533[_0x414c('0x31')](_0x414c('0x32'),_0x3f10d3+'-'+_0x58daed+'/'+_0x33484e)['json'](_0x27d542);}return null;};}function patchUpdates(_0x4abbbb){return function(_0x512e20){try{jsonpatch[_0x414c('0x33')](_0x512e20,_0x4abbbb,!![]);}catch(_0x326c97){return BPromise[_0x414c('0x34')](_0x326c97);}return _0x512e20['save']();};}function saveUpdates(_0x4f8ec5,_0x25ecbf){return function(_0x405dc6){if(_0x405dc6){return _0x405dc6[_0x414c('0x35')](_0x4f8ec5)[_0x414c('0x21')](function(_0x3b710b){return _0x3b710b;});}return null;};}function removeEntity(_0x1daaf8,_0x74965c){return function(_0x48f724){if(_0x48f724){return _0x48f724[_0x414c('0x36')]()[_0x414c('0x21')](function(){var _0x18f4ae=_0x48f724[_0x414c('0x37')]({'plain':!![]});var _0x2de84c='FaxAccounts';return db[_0x414c('0x38')][_0x414c('0x36')]({'where':{'type':_0x2de84c,'resourceId':_0x18f4ae['id']}})[_0x414c('0x21')](function(){return _0x48f724;});})[_0x414c('0x21')](function(){_0x1daaf8[_0x414c('0x2a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x19d0c0,_0x531a89){return function(_0x30c2b8){if(!_0x30c2b8){_0x19d0c0[_0x414c('0x39')](0x194);}return _0x30c2b8;};}function handleError(_0x210298,_0x176a04){_0x176a04=_0x176a04||0x1f4;return function(_0x1e884c){logger[_0x414c('0x26')](_0x1e884c[_0x414c('0x3a')]);if(_0x1e884c[_0x414c('0x3b')]){delete _0x1e884c[_0x414c('0x3b')];}_0x210298[_0x414c('0x2a')](_0x176a04)[_0x414c('0x3c')](_0x1e884c);};}exports[_0x414c('0x3d')]=function(_0x4d97a2,_0x4bdb16){var _0x3464cf={'include':[{'model':db['Pause'],'as':_0x414c('0x3e')}]},_0x30d9bb={},_0x5ae4b3={'count':0x0,'rows':[]};var _0x1b13fe=_[_0x414c('0x3f')](db['FaxAccount']['rawAttributes'],function(_0x1fa0b0){return{'name':_0x1fa0b0[_0x414c('0x40')],'type':_0x1fa0b0[_0x414c('0x41')][_0x414c('0x42')]};});_0x30d9bb[_0x414c('0x43')]=_[_0x414c('0x3f')](_0x1b13fe,_0x414c('0x3b'));_0x30d9bb[_0x414c('0x44')]=_[_0x414c('0x45')](_0x4d97a2['query']);_0x30d9bb[_0x414c('0x46')]=_[_0x414c('0x47')](_0x30d9bb[_0x414c('0x43')],_0x30d9bb[_0x414c('0x44')]);_0x3464cf[_0x414c('0x48')]=_['intersection'](_0x30d9bb['model'],qs[_0x414c('0x49')](_0x4d97a2[_0x414c('0x44')]['fields']));_0x3464cf['attributes']=_0x3464cf[_0x414c('0x48')][_0x414c('0x4a')]?_0x3464cf[_0x414c('0x48')]:_0x30d9bb[_0x414c('0x43')];if(!_0x4d97a2[_0x414c('0x44')][_0x414c('0x4b')](_0x414c('0x4c'))){_0x3464cf[_0x414c('0x2f')]=qs[_0x414c('0x2f')](_0x4d97a2[_0x414c('0x44')]['limit']);_0x3464cf[_0x414c('0x2d')]=qs['offset'](_0x4d97a2['query'][_0x414c('0x2d')]);}_0x3464cf[_0x414c('0x4d')]=qs['sort'](_0x4d97a2[_0x414c('0x44')][_0x414c('0x4e')]);_0x3464cf[_0x414c('0x4f')]=qs[_0x414c('0x46')](_[_0x414c('0x50')](_0x4d97a2[_0x414c('0x44')],_0x30d9bb[_0x414c('0x46')]),_0x1b13fe);if(_0x4d97a2[_0x414c('0x44')]['filter']){_0x3464cf[_0x414c('0x4f')]=_[_0x414c('0x51')](_0x3464cf[_0x414c('0x4f')],{'$or':_[_0x414c('0x3f')](_0x1b13fe,function(_0x59b168){if(_0x59b168[_0x414c('0x41')]!==_0x414c('0x52')){var _0x45b8c2={};_0x45b8c2[_0x59b168['name']]={'$like':'%'+_0x4d97a2[_0x414c('0x44')]['filter']+'%'};return _0x45b8c2;}})});}_0x3464cf=_['merge']({},_0x3464cf,_0x4d97a2['options']);var _0x39eea4={'where':_0x3464cf[_0x414c('0x4f')]};return db[_0x414c('0x53')][_0x414c('0x30')](_0x39eea4)[_0x414c('0x21')](function(_0x18211d){_0x5ae4b3[_0x414c('0x30')]=_0x18211d;if(_0x4d97a2[_0x414c('0x44')][_0x414c('0x54')]){_0x3464cf[_0x414c('0x55')]=[{'all':!![]}];}return db[_0x414c('0x53')][_0x414c('0x56')](_0x3464cf);})[_0x414c('0x21')](function(_0x2c0fd4){_0x5ae4b3['rows']=_0x2c0fd4;return _0x5ae4b3;})[_0x414c('0x21')](respondWithFilteredResult(_0x4bdb16,_0x3464cf))[_0x414c('0x57')](handleError(_0x4bdb16,null));};exports[_0x414c('0x58')]=function(_0x2281c3,_0x5c2f1d){var _0x530e81={'raw':![],'where':{'id':_0x2281c3[_0x414c('0x59')]['id']},'include':[{'model':db[_0x414c('0x5a')],'as':_0x414c('0x3e')}]},_0x5100f5={};_0x5100f5[_0x414c('0x43')]=_[_0x414c('0x45')](db[_0x414c('0x53')][_0x414c('0x5b')]);_0x5100f5[_0x414c('0x44')]=_[_0x414c('0x45')](_0x2281c3['query']);_0x5100f5['filters']=_[_0x414c('0x47')](_0x5100f5[_0x414c('0x43')],_0x5100f5['query']);_0x530e81[_0x414c('0x48')]=_[_0x414c('0x47')](_0x5100f5['model'],qs[_0x414c('0x49')](_0x2281c3[_0x414c('0x44')][_0x414c('0x49')]));_0x530e81[_0x414c('0x48')]=_0x530e81[_0x414c('0x48')][_0x414c('0x4a')]?_0x530e81[_0x414c('0x48')]:_0x5100f5[_0x414c('0x43')];if(_0x2281c3['query']['includeAll']){_0x530e81[_0x414c('0x55')]=[{'all':!![]}];}_0x530e81=_['merge']({},_0x530e81,_0x2281c3[_0x414c('0x5c')]);return db[_0x414c('0x53')][_0x414c('0x5d')](_0x530e81)[_0x414c('0x21')](handleEntityNotFound(_0x5c2f1d,null))[_0x414c('0x21')](respondWithResult(_0x5c2f1d,null))[_0x414c('0x57')](handleError(_0x5c2f1d,null));};exports['create']=function(_0x1ac4ab,_0x18ed33){return db[_0x414c('0x53')][_0x414c('0x5e')](_0x1ac4ab[_0x414c('0x5f')],{})['then'](function(_0xf6a48){var _0x4d45c2=_0x1ac4ab[_0x414c('0x60')][_0x414c('0x37')]({'plain':!![]});if(!_0x4d45c2)throw new Error(_0x414c('0x61'));if(_0x4d45c2['role']==='user'){var _0x3d84fe=_0xf6a48[_0x414c('0x37')]({'plain':!![]});var _0x23fe3b=_0x414c('0x62');return db['UserProfileSection'][_0x414c('0x5d')]({'where':{'name':_0x23fe3b,'userProfileId':_0x4d45c2[_0x414c('0x63')]},'raw':!![]})[_0x414c('0x21')](function(_0x1da48b){if(_0x1da48b&&_0x1da48b[_0x414c('0x64')]===0x0){return db[_0x414c('0x38')][_0x414c('0x5e')]({'name':_0x3d84fe[_0x414c('0x3b')],'resourceId':_0x3d84fe['id'],'type':_0x1da48b['name'],'sectionId':_0x1da48b['id']},{})[_0x414c('0x21')](function(){return _0xf6a48;});}else{return _0xf6a48;}})[_0x414c('0x57')](function(_0x51d82b){logger[_0x414c('0x26')](_0x414c('0x65'),_0x51d82b);throw _0x51d82b;});}return _0xf6a48;})[_0x414c('0x21')](respondWithResult(_0x18ed33,0xc9))[_0x414c('0x57')](handleError(_0x18ed33,null));};exports[_0x414c('0x35')]=function(_0x436407,_0xb8f0a8){if(_0x436407[_0x414c('0x5f')]['id']){delete _0x436407['body']['id'];}return db['FaxAccount'][_0x414c('0x5d')]({'where':{'id':_0x436407[_0x414c('0x59')]['id']},'include':[{'model':db['Pause'],'as':_0x414c('0x3e')}]})[_0x414c('0x21')](handleEntityNotFound(_0xb8f0a8,null))[_0x414c('0x21')](saveUpdates(_0x436407[_0x414c('0x5f')],null))[_0x414c('0x21')](respondWithResult(_0xb8f0a8,null))[_0x414c('0x57')](handleError(_0xb8f0a8,null));};exports['destroy']=function(_0x3f6fc6,_0x3b7d6f){return db[_0x414c('0x53')][_0x414c('0x5d')]({'where':{'id':_0x3f6fc6[_0x414c('0x59')]['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x3b7d6f,null))[_0x414c('0x21')](removeEntity(_0x3b7d6f,null))[_0x414c('0x57')](handleError(_0x3b7d6f,null));};exports[_0x414c('0x66')]=function(_0x5289d3,_0x3cba57){return db[_0x414c('0x53')]['describe']()['then'](respondWithResult(_0x3cba57,null))['catch'](handleError(_0x3cba57,null));};exports['addDisposition']=function(_0x1e3a65,_0x3dfee7,_0x139306){if(_0x1e3a65['body']['id']){delete _0x1e3a65[_0x414c('0x5f')]['id'];}return db[_0x414c('0x53')]['find']({'where':{'id':_0x1e3a65[_0x414c('0x59')]['id']}})['then'](handleEntityNotFound(_0x3dfee7,null))[_0x414c('0x21')](function(_0x2937ef){if(_0x2937ef){_0x1e3a65[_0x414c('0x5f')][_0x414c('0x67')]=_0x2937ef['id'];return db['Disposition'][_0x414c('0x5e')](_0x1e3a65[_0x414c('0x5f')]);}})['then'](respondWithResult(_0x3dfee7,null))[_0x414c('0x57')](handleError(_0x3dfee7,null));};exports[_0x414c('0x68')]=function(_0x51e4ea,_0x45d1be,_0x4d2773){var _0x5f13dd={'raw':![],'where':{}};var _0x37a839={};var _0x517732={'count':0x0,'rows':[]};return db[_0x414c('0x53')][_0x414c('0x69')]({'where':{'id':_0x51e4ea['params']['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x45d1be,null))[_0x414c('0x21')](function(_0x8795be){if(_0x8795be){_0x37a839[_0x414c('0x43')]=_[_0x414c('0x45')](db[_0x414c('0x6a')]['rawAttributes']);_0x37a839[_0x414c('0x44')]=_[_0x414c('0x45')](_0x51e4ea[_0x414c('0x44')]);_0x37a839['filters']=_[_0x414c('0x47')](_0x37a839[_0x414c('0x43')],_0x37a839[_0x414c('0x44')]);_0x5f13dd[_0x414c('0x48')]=_['intersection'](_0x37a839[_0x414c('0x43')],qs[_0x414c('0x49')](_0x51e4ea[_0x414c('0x44')][_0x414c('0x49')]));_0x5f13dd['attributes']=_0x5f13dd[_0x414c('0x48')][_0x414c('0x4a')]?_0x5f13dd['attributes']:_0x37a839[_0x414c('0x43')];if(!_0x51e4ea['query']['hasOwnProperty'](_0x414c('0x4c'))){_0x5f13dd[_0x414c('0x2f')]=qs[_0x414c('0x2f')](_0x51e4ea[_0x414c('0x44')][_0x414c('0x2f')]);_0x5f13dd[_0x414c('0x2d')]=qs['offset'](_0x51e4ea['query'][_0x414c('0x2d')]);}_0x5f13dd[_0x414c('0x4d')]=qs['sort'](_0x51e4ea['query']['sort']);_0x5f13dd[_0x414c('0x4f')]=qs[_0x414c('0x46')](_[_0x414c('0x50')](_0x51e4ea[_0x414c('0x44')],_0x37a839[_0x414c('0x46')]));_0x5f13dd[_0x414c('0x4f')][_0x414c('0x67')]=_0x8795be['id'];if(_0x51e4ea[_0x414c('0x44')]['filter']){_0x5f13dd[_0x414c('0x4f')]=_[_0x414c('0x51')](_0x5f13dd[_0x414c('0x4f')],{'$or':_[_0x414c('0x3f')](_0x5f13dd[_0x414c('0x48')],function(_0x36d022){var _0x8f2f57={};_0x8f2f57[_0x36d022]={'$like':'%'+_0x51e4ea[_0x414c('0x44')]['filter']+'%'};return _0x8f2f57;})});}_0x5f13dd=_[_0x414c('0x51')]({},_0x5f13dd,_0x51e4ea[_0x414c('0x5c')]);return db[_0x414c('0x6a')][_0x414c('0x30')]({'where':_0x5f13dd[_0x414c('0x4f')]})[_0x414c('0x21')](function(_0x1fbe1c){_0x517732[_0x414c('0x30')]=_0x1fbe1c;if(_0x51e4ea[_0x414c('0x44')][_0x414c('0x54')]){_0x5f13dd[_0x414c('0x55')]=[{'all':!![]}];}return db[_0x414c('0x6a')][_0x414c('0x56')](_0x5f13dd);})[_0x414c('0x21')](function(_0x256e51){_0x517732['rows']=_0x256e51;return _0x517732;});}})[_0x414c('0x21')](respondWithFilteredResult(_0x45d1be,_0x5f13dd))[_0x414c('0x57')](handleError(_0x45d1be,null));};exports[_0x414c('0x6b')]=function(_0x44a13d,_0x114674,_0x2ab12b){return db['FaxAccount'][_0x414c('0x5d')]({'where':{'id':_0x44a13d[_0x414c('0x59')]['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x114674,null))[_0x414c('0x21')](function(_0x5e2842){if(_0x5e2842){return _0x5e2842[_0x414c('0x6b')](_0x44a13d[_0x414c('0x44')][_0x414c('0x6c')]);}})['then'](respondWithStatusCode(_0x114674,null))['catch'](handleError(_0x114674,null));};exports[_0x414c('0x6d')]=function(_0x5cd9e4,_0xa3ac3,_0x34b4cd){if(_0x5cd9e4[_0x414c('0x5f')]['id']){delete _0x5cd9e4[_0x414c('0x5f')]['id'];}return db[_0x414c('0x53')][_0x414c('0x5d')]({'where':{'id':_0x5cd9e4[_0x414c('0x59')]['id']}})[_0x414c('0x21')](handleEntityNotFound(_0xa3ac3,null))[_0x414c('0x21')](function(_0x508b5b){if(_0x508b5b){_0x5cd9e4[_0x414c('0x5f')]['FaxAccountId']=_0x508b5b['id'];return db[_0x414c('0x6e')]['create'](_0x5cd9e4[_0x414c('0x5f')]);}})[_0x414c('0x21')](respondWithResult(_0xa3ac3,null))[_0x414c('0x57')](handleError(_0xa3ac3,null));};exports[_0x414c('0x6f')]=function(_0x56ae31,_0x4862e8,_0x163f4f){var _0x44d960={'raw':![],'where':{}};var _0x29b793={};var _0x9eefea={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x56ae31[_0x414c('0x59')]['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x4862e8,null))['then'](function(_0xaa18f8){if(_0xaa18f8){_0x29b793[_0x414c('0x43')]=_[_0x414c('0x45')](db[_0x414c('0x6e')][_0x414c('0x5b')]);_0x29b793[_0x414c('0x44')]=_[_0x414c('0x45')](_0x56ae31[_0x414c('0x44')]);_0x29b793[_0x414c('0x46')]=_[_0x414c('0x47')](_0x29b793[_0x414c('0x43')],_0x29b793['query']);_0x44d960[_0x414c('0x48')]=_[_0x414c('0x47')](_0x29b793[_0x414c('0x43')],qs['fields'](_0x56ae31[_0x414c('0x44')][_0x414c('0x49')]));_0x44d960[_0x414c('0x48')]=_0x44d960[_0x414c('0x48')][_0x414c('0x4a')]?_0x44d960[_0x414c('0x48')]:_0x29b793['model'];if(!_0x56ae31[_0x414c('0x44')][_0x414c('0x4b')](_0x414c('0x4c'))){_0x44d960['limit']=qs['limit'](_0x56ae31[_0x414c('0x44')][_0x414c('0x2f')]);_0x44d960[_0x414c('0x2d')]=qs['offset'](_0x56ae31[_0x414c('0x44')][_0x414c('0x2d')]);}_0x44d960[_0x414c('0x4d')]=qs['sort'](_0x56ae31[_0x414c('0x44')][_0x414c('0x4e')]);_0x44d960[_0x414c('0x4f')]=qs[_0x414c('0x46')](_[_0x414c('0x50')](_0x56ae31[_0x414c('0x44')],_0x29b793['filters']));_0x44d960[_0x414c('0x4f')][_0x414c('0x67')]=_0xaa18f8['id'];if(_0x56ae31[_0x414c('0x44')][_0x414c('0x70')]){_0x44d960['where']=_[_0x414c('0x51')](_0x44d960[_0x414c('0x4f')],{'$or':_[_0x414c('0x3f')](_0x44d960[_0x414c('0x48')],function(_0x4c6079){var _0xb6a6db={};_0xb6a6db[_0x4c6079]={'$like':'%'+_0x56ae31[_0x414c('0x44')]['filter']+'%'};return _0xb6a6db;})});}_0x44d960=_['merge']({},_0x44d960,_0x56ae31[_0x414c('0x5c')]);return db[_0x414c('0x6e')][_0x414c('0x30')]({'where':_0x44d960['where']})[_0x414c('0x21')](function(_0x43a097){_0x9eefea['count']=_0x43a097;if(_0x56ae31[_0x414c('0x44')][_0x414c('0x54')]){_0x44d960[_0x414c('0x55')]=[{'all':!![]}];}return db[_0x414c('0x6e')]['findAll'](_0x44d960);})['then'](function(_0x2cd861){_0x9eefea[_0x414c('0x71')]=_0x2cd861;return _0x9eefea;});}})[_0x414c('0x21')](respondWithFilteredResult(_0x4862e8,_0x44d960))[_0x414c('0x57')](handleError(_0x4862e8,null));};exports['removeAnswers']=function(_0x260c89,_0x533a65,_0x3de0e2){return db['FaxAccount'][_0x414c('0x5d')]({'where':{'id':_0x260c89['params']['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x533a65,null))[_0x414c('0x21')](function(_0x361576){if(_0x361576){return _0x361576[_0x414c('0x72')](_0x260c89[_0x414c('0x44')][_0x414c('0x6c')]);}})[_0x414c('0x21')](respondWithStatusCode(_0x533a65,null))[_0x414c('0x57')](handleError(_0x533a65,null));};exports[_0x414c('0x73')]=function(_0x3560cc,_0x4e326a,_0x5ee646){return db['FaxInteraction']['find']({'where':{'id':_0x3560cc[_0x414c('0x59')]['id']}})['then'](handleEntityNotFound(_0x4e326a,null))[_0x414c('0x21')](function(_0x56bece){if(_0x56bece){return _0x56bece[_0x414c('0x73')](_0x3560cc[_0x414c('0x5f')][_0x414c('0x6c')],_[_0x414c('0x74')](_0x3560cc[_0x414c('0x5f')],[_0x414c('0x6c'),'id'])||{});}})[_0x414c('0x21')](respondWithResult(_0x4e326a,null))[_0x414c('0x57')](handleError(_0x4e326a,null));};exports[_0x414c('0x75')]=function(_0x725f13,_0x4f7c44,_0x1fd83b){var _0x38c448={'raw':![],'where':{}};var _0x14cddb={};var _0x1fd338={'count':0x0,'rows':[]};return db[_0x414c('0x53')][_0x414c('0x69')]({'where':{'id':_0x725f13[_0x414c('0x59')]['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x4f7c44,null))[_0x414c('0x21')](function(_0x433c3e){if(_0x433c3e){_0x14cddb[_0x414c('0x43')]=_['keys'](db[_0x414c('0x76')][_0x414c('0x5b')]);_0x14cddb[_0x414c('0x44')]=_['keys'](_0x725f13[_0x414c('0x44')]);_0x14cddb[_0x414c('0x46')]=_['intersection'](_0x14cddb[_0x414c('0x43')],_0x14cddb['query']);_0x38c448['attributes']=_[_0x414c('0x47')](_0x14cddb[_0x414c('0x43')],qs[_0x414c('0x49')](_0x725f13[_0x414c('0x44')][_0x414c('0x49')]));_0x38c448['attributes']=_0x38c448[_0x414c('0x48')][_0x414c('0x4a')]?_0x38c448[_0x414c('0x48')]:_0x14cddb[_0x414c('0x43')];if(!_0x725f13['query'][_0x414c('0x4b')](_0x414c('0x4c'))){_0x38c448['limit']=qs['limit'](_0x725f13['query'][_0x414c('0x2f')]);_0x38c448[_0x414c('0x2d')]=qs[_0x414c('0x2d')](_0x725f13[_0x414c('0x44')][_0x414c('0x2d')]);}_0x38c448['order']=qs['sort'](_0x725f13[_0x414c('0x44')][_0x414c('0x4e')]);_0x38c448[_0x414c('0x4f')]=qs[_0x414c('0x46')](_[_0x414c('0x50')](_0x725f13['query'],_0x14cddb[_0x414c('0x46')]));_0x38c448[_0x414c('0x4f')][_0x414c('0x67')]=_0x433c3e['id'];if(_0x725f13[_0x414c('0x44')][_0x414c('0x70')]){_0x38c448[_0x414c('0x4f')]=_[_0x414c('0x51')](_0x38c448[_0x414c('0x4f')],{'$or':_[_0x414c('0x3f')](_0x38c448[_0x414c('0x48')],function(_0x1202f5){var _0x398758={};_0x398758[_0x1202f5]={'$like':'%'+_0x725f13[_0x414c('0x44')]['filter']+'%'};return _0x398758;})});}_0x38c448=_[_0x414c('0x51')]({},_0x38c448,_0x725f13[_0x414c('0x5c')]);return db[_0x414c('0x76')]['count']({'where':_0x38c448[_0x414c('0x4f')]})[_0x414c('0x21')](function(_0x6a79e2){_0x1fd338[_0x414c('0x30')]=_0x6a79e2;if(_0x725f13[_0x414c('0x44')][_0x414c('0x54')]){_0x38c448['include']=[{'model':db[_0x414c('0x77')],'as':_0x414c('0x78'),'required':![]},{'model':db[_0x414c('0x79')],'as':'Owner','attributes':[_0x414c('0x3b'),_0x414c('0x7a'),'internal'],'required':![]},{'model':db[_0x414c('0x7b')],'as':_0x414c('0x7c'),'attributes':['id','name',_0x414c('0x7d')],'where':_0x725f13[_0x414c('0x44')]['tag']?{'id':_0x725f13[_0x414c('0x44')][_0x414c('0x7e')]}:undefined,'required':_0x725f13['query'][_0x414c('0x7e')]?!![]:![]}];}return db[_0x414c('0x76')][_0x414c('0x56')](_0x38c448);})[_0x414c('0x21')](function(_0x148d54){_0x1fd338[_0x414c('0x71')]=_0x148d54;return _0x1fd338;});}})['then'](respondWithFilteredResult(_0x4f7c44,_0x38c448))[_0x414c('0x57')](handleError(_0x4f7c44,null));};exports[_0x414c('0x7f')]=function(_0x3bf440,_0x4c4de8){var _0x1c8dbd=_0x3bf440[_0x414c('0x59')]['id'];var _0xe47ef0=_0x3bf440[_0x414c('0x5f')];var _0x3134ca=0xc8;var _0x9dee6a=null;return db[_0x414c('0x80')][_0x414c('0x81')]({'isolationLevel':db[_0x414c('0x80')][_0x414c('0x82')][_0x414c('0x83')]['READ_COMMITTED']},function(_0x15b819){return db[_0x414c('0x53')][_0x414c('0x69')]({'where':{'id':_0x1c8dbd},'transaction':_0x15b819})[_0x414c('0x21')](function(_0xedf835){if(_0xedf835){return db[_0x414c('0x84')][_0x414c('0x36')]({'where':{'FaxAccountId':_0x1c8dbd},'transaction':_0x15b819})['then'](function(){var _0x171798=_[_0x414c('0x3f')](_0xe47ef0,function(_0x36012c){_0x36012c['FaxAccountId']=_0x1c8dbd;return _0x36012c;});return db[_0x414c('0x84')][_0x414c('0x85')](_0x171798,{'transaction':_0x15b819});});}else{_0x3134ca=0x194;_0x9dee6a=[];}});})[_0x414c('0x21')](function(){if(_0x3134ca!==0x194){return db[_0x414c('0x84')][_0x414c('0x86')]({'where':{'FaxAccountId':_0x1c8dbd},'order':'priority'})[_0x414c('0x21')](function(_0x3bd2d2){_0x9dee6a=_0x3bd2d2;});}})[_0x414c('0x57')](function(_0x139391){_0x3134ca=0x1f4;logger[_0x414c('0x26')](_0x139391['stack']);if(_0x139391[_0x414c('0x3b')]){delete _0x139391[_0x414c('0x3b')];}_0x9dee6a=_0x139391;})['finally'](function(){if(_0x9dee6a===null){_0x4c4de8[_0x414c('0x39')](_0x3134ca);}else{if(_0x3134ca===0x1f4){_0x4c4de8[_0x414c('0x2a')](_0x3134ca)[_0x414c('0x3c')](_0x9dee6a);}else{_0x4c4de8[_0x414c('0x2a')](_0x3134ca)[_0x414c('0x2c')](_0x9dee6a);}}});};exports[_0x414c('0x87')]=function(_0x56b4ea,_0x7f667c,_0x396134){var _0x32d46a={};var _0x149a2c={};var _0x2ab87c;var _0x6ae674;return db[_0x414c('0x53')][_0x414c('0x69')]({'where':{'id':_0x56b4ea[_0x414c('0x59')]['id']}})['then'](handleEntityNotFound(_0x7f667c,null))[_0x414c('0x21')](function(_0x51282d){if(_0x51282d){_0x2ab87c=_0x51282d;_0x149a2c[_0x414c('0x43')]=_[_0x414c('0x45')](db[_0x414c('0x84')][_0x414c('0x5b')]);_0x149a2c[_0x414c('0x44')]=_[_0x414c('0x45')](_0x56b4ea[_0x414c('0x44')]);_0x149a2c[_0x414c('0x46')]=_[_0x414c('0x47')](_0x149a2c[_0x414c('0x43')],_0x149a2c['query']);_0x32d46a[_0x414c('0x48')]=_['intersection'](_0x149a2c[_0x414c('0x43')],qs[_0x414c('0x49')](_0x56b4ea[_0x414c('0x44')][_0x414c('0x49')]));_0x32d46a[_0x414c('0x48')]=_0x32d46a[_0x414c('0x48')][_0x414c('0x4a')]?_0x32d46a['attributes']:_0x149a2c['model'];_0x32d46a[_0x414c('0x4d')]=qs[_0x414c('0x4e')](_0x56b4ea['query'][_0x414c('0x4e')]);_0x32d46a[_0x414c('0x4f')]=qs[_0x414c('0x46')](_['pick'](_0x56b4ea[_0x414c('0x44')],_0x149a2c[_0x414c('0x46')]));if(_0x56b4ea[_0x414c('0x44')][_0x414c('0x70')]){_0x32d46a[_0x414c('0x4f')]=_[_0x414c('0x51')](_0x32d46a['where'],{'$or':_[_0x414c('0x3f')](_0x32d46a[_0x414c('0x48')],function(_0x414df5){var _0x405efc={};_0x405efc[_0x414df5]={'$like':'%'+_0x56b4ea['query'][_0x414c('0x70')]+'%'};return _0x405efc;})});}_0x32d46a=_[_0x414c('0x51')]({},_0x32d46a,_0x56b4ea[_0x414c('0x5c')]);return _0x2ab87c['getApplications'](_0x32d46a);}})[_0x414c('0x21')](function(_0x244d7c){if(_0x244d7c){_0x6ae674=_0x244d7c['length'];if(!_0x56b4ea[_0x414c('0x44')][_0x414c('0x4b')](_0x414c('0x4c'))){_0x32d46a[_0x414c('0x2f')]=qs[_0x414c('0x2f')](_0x56b4ea['query'][_0x414c('0x2f')]);_0x32d46a[_0x414c('0x2d')]=qs['offset'](_0x56b4ea[_0x414c('0x44')]['offset']);}return _0x2ab87c[_0x414c('0x87')](_0x32d46a);}})[_0x414c('0x21')](function(_0x553153){if(_0x553153){return _0x553153?{'count':_0x6ae674,'rows':_0x553153}:null;}})['then'](respondWithResult(_0x7f667c,null))[_0x414c('0x57')](handleError(_0x7f667c,null));};function Extension(_0x5e2b9a,_0x39a69f,_0x59faf2,_0x1681bb){this[_0x414c('0x88')]=_0x414c('0x89');this[_0x414c('0x8a')]=_0x5e2b9a[_0x414c('0x8b')];this['app']=_0x1681bb;this[_0x414c('0x41')]=_0x414c('0x8c');this[_0x414c('0x8d')]=_0x414c('0x8e');this[_0x414c('0x67')]=_0x5e2b9a['id'];this[_0x414c('0x8f')]=_0x39a69f;this['appdata']=_0x59faf2;}function createExtensionsReciveFax(_0x2c1f1a){var _0x16c8b6=0x1;var _0x3096b4=[];_0x3096b4[_0x414c('0x90')](new Extension(_0x2c1f1a,_0x16c8b6,'','Answer'));_0x16c8b6+=0x1;_0x3096b4[_0x414c('0x90')](new Extension(_0x2c1f1a,_0x16c8b6,_0x414c('0x91'),_0x414c('0x92')));_0x16c8b6+=0x1;for(var _0x357229 in _0x2c1f1a){if(_0x2c1f1a[_0x414c('0x4b')](_0x357229)&&(_0x357229===_0x414c('0x93')||_0x357229==='localstationid'||_0x357229===_0x414c('0x94')||_0x357229===_0x414c('0x95')||_0x357229===_0x414c('0x96')||_0x357229===_0x414c('0x97')||_0x357229==='minrate'||_0x357229===_0x414c('0x98')||_0x357229===_0x414c('0x99'))){_0x3096b4[_0x414c('0x90')](new Extension(_0x2c1f1a,_0x16c8b6,_0x414c('0x9a')+_0x357229+')='+_0x2c1f1a[_0x357229],_0x414c('0x92')));_0x16c8b6+=0x1;}}_0x3096b4[_0x414c('0x90')](new Extension(_0x2c1f1a,_0x16c8b6,'6',_0x414c('0x9b')));_0x16c8b6+=0x1;_0x3096b4[_0x414c('0x90')](new Extension(_0x2c1f1a,_0x16c8b6,_0x414c('0x9c'),_0x414c('0x9d')));_0x16c8b6=0x0;return _0x3096b4;}exports['addAccountApplications']=function(_0x6d0980,_0x890b0f,_0x192091){var _0x3a4ca2;return db[_0x414c('0x80')]['transaction'](function(_0x53066c){return db[_0x414c('0x53')]['create'](_0x6d0980[_0x414c('0x5f')],{'transaction':_0x53066c})[_0x414c('0x21')](function(_0x461d36){_0x3a4ca2=_0x461d36[_0x414c('0x37')]({'plain':!![]});return db[_0x414c('0x9e')][_0x414c('0x85')](createExtensionsReciveFax(_0x3a4ca2),{'transaction':_0x53066c});});})[_0x414c('0x21')](function(){return _0x3a4ca2;})[_0x414c('0x21')](respondWithResult(_0x890b0f,null))[_0x414c('0x57')](handleError(_0x890b0f,null));};exports[_0x414c('0x9f')]=function(_0x5713b0,_0x5a0364,_0x26065b){var _0x42dd85;return db['sequelize'][_0x414c('0x81')](function(_0x208026){return db[_0x414c('0x53')]['update'](_0x5713b0[_0x414c('0x5f')],{'where':{'id':_0x5713b0[_0x414c('0x5f')]['id']},'transaction':_0x208026})[_0x414c('0x21')](function(_0x6cf24a){return db[_0x414c('0x9e')][_0x414c('0x36')]({'where':{'FaxAccountId':_0x5713b0[_0x414c('0x5f')]['id']},'transaction':_0x208026})['then'](function(_0x30a712){return db[_0x414c('0x9e')][_0x414c('0x85')](createExtensionsReciveFax(_[_0x414c('0x74')](_0x5713b0[_0x414c('0x5f')],[_0x414c('0xa0'),'key',_0x414c('0xa1'),_0x414c('0xa2'),_0x414c('0xa3'),_0x414c('0xa4')])),{'transaction':_0x208026});});});})['then'](function(){return db['FaxAccount'][_0x414c('0xa5')](_0x5713b0[_0x414c('0x5f')]['id']);})['then'](respondWithResult(_0x5a0364,null))[_0x414c('0x57')](handleError(_0x5a0364,null));};exports[_0x414c('0xa6')]=function(_0x40df90,_0x35f2d0,_0x1d5c92){var _0x4b1aab={'raw':!![],'where':{}};var _0xb61223={};var _0x5b347f={'count':0x0,'rows':[]};return db[_0x414c('0x53')][_0x414c('0x69')]({'where':{'id':_0x40df90['params']['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x35f2d0,null))[_0x414c('0x21')](function(_0x2adcdf){if(_0x2adcdf){_0xb61223['model']=_[_0x414c('0x45')](db['FaxMessage'][_0x414c('0x5b')]);_0xb61223[_0x414c('0x44')]=_[_0x414c('0x45')](_0x40df90[_0x414c('0x44')]);_0xb61223[_0x414c('0x46')]=_[_0x414c('0x47')](_0xb61223['model'],_0xb61223['query']);_0x4b1aab[_0x414c('0x48')]=_['intersection'](_0xb61223[_0x414c('0x43')],qs['fields'](_0x40df90[_0x414c('0x44')]['fields']));_0x4b1aab[_0x414c('0x48')]=_0x4b1aab[_0x414c('0x48')][_0x414c('0x4a')]?_0x4b1aab[_0x414c('0x48')]:_0xb61223[_0x414c('0x43')];if(!_0x40df90[_0x414c('0x44')][_0x414c('0x4b')]('nolimit')){_0x4b1aab[_0x414c('0x2f')]=qs[_0x414c('0x2f')](_0x40df90[_0x414c('0x44')][_0x414c('0x2f')]);_0x4b1aab[_0x414c('0x2d')]=qs[_0x414c('0x2d')](_0x40df90[_0x414c('0x44')][_0x414c('0x2d')]);}_0x4b1aab[_0x414c('0x4d')]=qs['sort'](_0x40df90[_0x414c('0x44')][_0x414c('0x4e')]);_0x4b1aab[_0x414c('0x4f')]=qs[_0x414c('0x46')](_['pick'](_0x40df90[_0x414c('0x44')],_0xb61223[_0x414c('0x46')]));_0x4b1aab['where'][_0x414c('0x67')]=_0x2adcdf['id'];if(_0x40df90[_0x414c('0x44')][_0x414c('0x70')]){_0x4b1aab[_0x414c('0x4f')]=_[_0x414c('0x51')](_0x4b1aab[_0x414c('0x4f')],{'$or':_['map'](_0x4b1aab['attributes'],function(_0x12512d){var _0x2e1c99={};_0x2e1c99[_0x12512d]={'$like':'%'+_0x40df90[_0x414c('0x44')][_0x414c('0x70')]+'%'};return _0x2e1c99;})});}if(_0x40df90['query'][_0x414c('0xa7')]){var _0x4473a0=_0x40df90[_0x414c('0x44')]['$gte'][_0x414c('0xa8')](',');var _0xb1db6d={};_0xb1db6d[_0x4473a0[0x0]]={'$gte':moment(_0x4473a0[0x1])[_0x414c('0xa9')](_0x414c('0xaa'))};_0x4b1aab[_0x414c('0x4f')]=_[_0x414c('0x51')](_0x4b1aab[_0x414c('0x4f')],_0xb1db6d);}_0x4b1aab=_[_0x414c('0x51')]({},_0x4b1aab,_0x40df90[_0x414c('0x5c')]);return db[_0x414c('0xab')][_0x414c('0x30')]({'where':_0x4b1aab[_0x414c('0x4f')]})[_0x414c('0x21')](function(_0x1e620e){_0x5b347f[_0x414c('0x30')]=_0x1e620e;if(_0x40df90[_0x414c('0x44')][_0x414c('0x54')]){_0x4b1aab['include']=[{'all':!![]}];}return db['FaxMessage'][_0x414c('0x56')](_0x4b1aab);})['then'](function(_0x558888){_0x5b347f[_0x414c('0x71')]=_0x558888;return _0x5b347f;});}})[_0x414c('0x21')](respondWithFilteredResult(_0x35f2d0,_0x4b1aab))['catch'](handleError(_0x35f2d0,null));};exports['send']=function(_0x479a9a,_0x26112c,_0x917168){var _0x88ed65,_0x35ace8={},_0x51ce74;if(_0x479a9a[_0x414c('0x5f')]['to']){_0x51ce74=_0x479a9a[_0x414c('0x5f')]['to'][0x0];}return db[_0x414c('0x53')][_0x414c('0x5d')]({'where':{'id':_0x479a9a['params']['id']},'include':[{'model':db[_0x414c('0xac')],'as':_0x414c('0xad'),'include':[{'model':db[_0x414c('0x77')],'as':'Contacts','where':{'fax':_0x51ce74},'limit':0x1,'order':[[_0x414c('0xa2'),_0x414c('0xae')]]}]}]})['then'](handleEntityNotFound(_0x26112c,null))[_0x414c('0x21')](function(_0x16010b){_0x88ed65=_0x16010b;if(_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')]&&_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][_0x414c('0x4a')]){for(var _0x2a1833=0x0;_0x2a1833<_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][_0x414c('0x4a')];_0x2a1833+=0x1){_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][_0x2a1833]={'filename':_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][_0x2a1833]['name'],'id':_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][_0x2a1833]['id'],'path':path[_0x414c('0xb0')](config[_0x414c('0xb1')],_0x414c('0xb2'),_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][_0x2a1833][_0x414c('0xb3')])};}}return respondWithRpcPromise(_0x414c('0xb4'),_0x414c('0xb4'),{'FaxAccountId':_[_0x414c('0xb5')](_0x479a9a[_0x414c('0x59')]['id'])?undefined:_0x479a9a[_0x414c('0x59')]['id'],'path':_['isNil'](_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][0x0][_0x414c('0x8')])?undefined:_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][0x0][_0x414c('0x8')],'fax':_[_0x414c('0xb5')](_0x479a9a['body']['to'][0x0])?undefined:_0x479a9a[_0x414c('0x5f')]['to'][0x0]},client9002);})[_0x414c('0x21')](function(){if(_0x88ed65){if(_[_0x414c('0xb5')](_0x479a9a[_0x414c('0x5f')][_0x414c('0xb6')])){_0x479a9a[_0x414c('0x5f')][_0x414c('0xb6')]=util[_0x414c('0xa9')](_0x414c('0xb7'),_0x88ed65[_0x414c('0x3b')],_0x88ed65[_0x414c('0xb8')]);}if(_0x88ed65[_0x414c('0xad')]){if(_0x88ed65['List']['Contacts']['length']){return _0x88ed65['List'][_0x414c('0xb9')][0x0];}else{return db[_0x414c('0x77')][_0x414c('0x5e')](_['defaults'](_0x479a9a[_0x414c('0x5f')],{'firstName':_0x479a9a[_0x414c('0x5f')]['to'][0x0],'phone':_0x479a9a[_0x414c('0x5f')]['to'][0x0],'fax':_0x479a9a[_0x414c('0x5f')]['to'][0x0],'ListId':_0x88ed65[_0x414c('0xa4')]}));}}else{throw new Error(_0x414c('0xba'));}}else{throw new Error(_0x414c('0xbb'));}})[_0x414c('0x21')](function(_0x4dc44c){if(_0x4dc44c){return db[_0x414c('0x76')][_0x414c('0x5d')]({'where':{'ContactId':_0x4dc44c['id'],'closed':![],'FaxAccountId':_0x88ed65['id']}})['then'](function(_0x32f61f){if(_0x32f61f){return[_0x32f61f,![]];}return db['FaxInteraction'][_0x414c('0x5e')]({'UserId':_0x479a9a['user']['id'],'ContactId':_0x4dc44c['id'],'FaxAccountId':_0x88ed65['id'],'fax':_0x479a9a['body']['to'][0x0],'firstMsgDirection':_0x414c('0xbc'),'Messages':[_[_0x414c('0x51')](_0x479a9a[_0x414c('0x5f')],{'read':![],'body':_0x479a9a[_0x414c('0x5f')]['attachments'][0x0][_0x414c('0xbd')],'FaxAccountId':_0x88ed65['id'],'UserId':_0x479a9a[_0x414c('0x60')]['id'],'ContactId':_0x4dc44c['id'],'AttachmentId':_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][0x0]['id']})]},{'include':[{'model':db[_0x414c('0xab')],'as':_0x414c('0xbe')}]})[_0x414c('0x21')](function(_0xb4c6ad){return[_0xb4c6ad,!![]];});});}else{throw new Error(_0x414c('0xbf'));}})['spread'](function(_0x39caa1,_0x41e22c){if(_0x41e22c){return _0x39caa1;}return db[_0x414c('0xab')][_0x414c('0x5e')]({'direction':_0x414c('0xbc'),'read':![],'body':_0x479a9a[_0x414c('0x5f')]['attachments'][0x0][_0x414c('0xbd')],'FaxAccountId':_0x88ed65['id'],'FaxInteractionId':_0x39caa1['id'],'UserId':_0x479a9a['user']['id'],'ContactId':_0x39caa1[_0x414c('0xc0')],'AttachmentId':_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][0x0]['id']})[_0x414c('0x21')](function(_0x15c083){_0x39caa1[_0x414c('0xc1')][_0x414c('0xbe')]=[];_0x39caa1[_0x414c('0xc1')][_0x414c('0xbe')]['push'](_0x15c083[_0x414c('0xc1')]);return _0x39caa1;});})['then'](function(_0x2c062d){respondWithRpcPromise('SendFax',_0x414c('0xc2'),{'FaxAccountId':_[_0x414c('0xb5')](_0x479a9a['params']['id'])?undefined:_0x479a9a[_0x414c('0x59')]['id'],'path':_[_0x414c('0xb5')](_0x479a9a[_0x414c('0x5f')]['attachments'][0x0][_0x414c('0x8')])?undefined:_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][0x0][_0x414c('0x8')],'fax':_[_0x414c('0xb5')](_0x479a9a['body']['to'][0x0])?undefined:_0x479a9a['body']['to'][0x0],'AttachmentId':_0x479a9a[_0x414c('0x5f')][_0x414c('0xaf')][0x0]['id']},client9002)[_0x414c('0x21')](function(_0x32cbac){logger[_0x414c('0x22')](_0x414c('0xc3'),_0x32cbac);})[_0x414c('0x57')](function(_0x47824c){logger[_0x414c('0x22')](_0x414c('0xc3'),_0x47824c);});return _0x2c062d;})['then'](respondWithResult(_0x26112c,null))[_0x414c('0x57')](handleError(_0x26112c,null));};exports[_0x414c('0xc4')]=function(_0xd8b2f0,_0x5e8c5e,_0x4f43ae){return db[_0x414c('0x53')]['find']({'where':{'id':_0xd8b2f0['params']['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x5e8c5e,null))['then'](function(_0xd25c2d){if(_0xd25c2d){return _0xd25c2d['addAgents'](_0xd8b2f0[_0x414c('0x5f')][_0x414c('0x6c')],_[_0x414c('0x74')](_0xd8b2f0['body'],[_0x414c('0x6c'),'id'])||{})['spread'](function(_0x4a4d90){for(var _0x76732e=0x0;_0x76732e<_0xd8b2f0['body'][_0x414c('0x6c')][_0x414c('0x4a')];_0x76732e+=0x1){socket[_0x414c('0xc5')]('userFaxAccount:save',{'UserId':Number(_0xd8b2f0['body'][_0x414c('0x6c')][_0x76732e]),'FaxAccountId':Number(_0xd8b2f0[_0x414c('0x59')]['id'])});}return _0x4a4d90;});}})[_0x414c('0x21')](respondWithResult(_0x5e8c5e,null))[_0x414c('0x57')](handleError(_0x5e8c5e,null));};exports[_0x414c('0xc6')]=function(_0xf1083b,_0x38e7b0,_0x3c9e6c){return db[_0x414c('0x53')]['find']({'where':{'id':_0xf1083b[_0x414c('0x59')]['id']}})['then'](handleEntityNotFound(_0x38e7b0,null))['then'](function(_0x3681d0){if(_0x3681d0){return _0x3681d0[_0x414c('0xc6')](_0xf1083b['query'][_0x414c('0x6c')])['then'](function(){if(_[_0x414c('0xc7')](_0xf1083b[_0x414c('0x44')][_0x414c('0x6c')])){for(var _0x416066=0x0;_0x416066<_0xf1083b['query']['ids'][_0x414c('0x4a')];_0x416066+=0x1){socket[_0x414c('0xc5')](_0x414c('0xc8'),{'UserId':Number(_0xf1083b['query'][_0x414c('0x6c')][_0x416066]),'FaxAccountId':Number(_0xf1083b[_0x414c('0x59')]['id'])});}}else{socket['emit']('userFaxAccount:remove',{'UserId':Number(_0xf1083b['query'][_0x414c('0x6c')]),'FaxAccountId':Number(_0xf1083b[_0x414c('0x59')]['id'])});}});}})['then'](respondWithStatusCode(_0x38e7b0,null))['catch'](handleError(_0x38e7b0,null));};exports[_0x414c('0xc9')]=function(_0x1ec18f,_0x3a98bd,_0x2f80a8){var _0x3a252c={};var _0x108dbd={};var _0x2f4298;var _0x7f291e;return db[_0x414c('0x53')][_0x414c('0x69')]({'where':{'id':_0x1ec18f[_0x414c('0x59')]['id']}})[_0x414c('0x21')](handleEntityNotFound(_0x3a98bd,null))[_0x414c('0x21')](function(_0x233791){if(_0x233791){_0x2f4298=_0x233791;_0x108dbd[_0x414c('0x43')]=_['keys'](db['User']['rawAttributes']);_0x108dbd[_0x414c('0x44')]=_[_0x414c('0x45')](_0x1ec18f[_0x414c('0x44')]);_0x108dbd[_0x414c('0x46')]=_['intersection'](_0x108dbd['model'],_0x108dbd[_0x414c('0x44')]);_0x3a252c[_0x414c('0x48')]=_[_0x414c('0x47')](_0x108dbd[_0x414c('0x43')],qs[_0x414c('0x49')](_0x1ec18f[_0x414c('0x44')][_0x414c('0x49')]));_0x3a252c['attributes']=_0x3a252c[_0x414c('0x48')][_0x414c('0x4a')]?_0x3a252c[_0x414c('0x48')]:_0x108dbd['model'];_0x3a252c['order']=qs['sort'](_0x1ec18f[_0x414c('0x44')][_0x414c('0x4e')]);_0x3a252c[_0x414c('0x4f')]=qs[_0x414c('0x46')](_['pick'](_0x1ec18f[_0x414c('0x44')],_0x108dbd['filters']));if(_0x1ec18f[_0x414c('0x44')]['filter']){_0x3a252c['where']=_['merge'](_0x3a252c[_0x414c('0x4f')],{'$or':_['map'](_0x3a252c[_0x414c('0x48')],function(_0xd3e0b9){var _0xac0963={};_0xac0963[_0xd3e0b9]={'$like':'%'+_0x1ec18f[_0x414c('0x44')][_0x414c('0x70')]+'%'};return _0xac0963;})});}_0x3a252c=_[_0x414c('0x51')]({},_0x3a252c,_0x1ec18f['options']);return _0x2f4298[_0x414c('0xc9')](_0x3a252c);}})[_0x414c('0x21')](function(_0xcdbfa0){if(_0xcdbfa0){_0x7f291e=_0xcdbfa0[_0x414c('0x4a')];if(!_0x1ec18f[_0x414c('0x44')]['hasOwnProperty'](_0x414c('0x4c'))){_0x3a252c[_0x414c('0x2f')]=qs[_0x414c('0x2f')](_0x1ec18f[_0x414c('0x44')][_0x414c('0x2f')]);_0x3a252c[_0x414c('0x2d')]=qs[_0x414c('0x2d')](_0x1ec18f[_0x414c('0x44')][_0x414c('0x2d')]);}return _0x2f4298[_0x414c('0xc9')](_0x3a252c);}})[_0x414c('0x21')](function(_0x3acf4){if(_0x3acf4){return _0x3acf4?{'count':_0x7f291e,'rows':_0x3acf4}:null;}})['then'](respondWithResult(_0x3a98bd,null))[_0x414c('0x57')](handleError(_0x3a98bd,null));};
\ No newline at end of file