Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index d338d3e..c59e875 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb30a=['isNil','from','\x22%s\x22\x20<%s>','fax','List\x20not\x20found','Send\x20Fax\x20failed','out','Messages','Contact\x20not\x20found','spread','filename','ContactId','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','removeAgents','userFaxAccount:remove','getAgents','html-pdf','eml-format','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','defaults','socket.io-emitter','./faxAccount.socket','register','jayson/promise','client','http','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','sendStatus','end','status','offset','limit','set','Content-Range','json','apply','reject','save','destroy','get','FaxAccounts','UserProfileResource','stack','name','send','Pause','map','FaxAccount','rawAttributes','fieldName','type','key','model','query','intersection','attributes','length','nolimit','sort','where','filters','merge','VIRTUAL','filter','options','count','includeAll','findAll','rows','show','mandatoryDispositionPause','keys','fields','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','describe','addDisposition','FaxAccountId','Disposition','getDispositions','order','pick','include','removeDispositions','ids','CannedAnswer','getAnswers','findOne','hasOwnProperty','removeAnswers','addInteraction','FaxInteraction','CmContact','Contact','User','Owner','fullname','internal','Tags','color','tag','addApplications','transaction','FaxApplication','bulkCreate','findAndCountAll','priority','getApplications','context','from-voip-provider','exten','localstationid','app','system','Fax\x20Extension','appdata','Answer','push','Set','gateway','headerinfo','t38timeout','FAXOPT(','Wait','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','ReceiveFax','addAccountApplications','sequelize','VoiceExtension','omit','tech','createdAt','updatedAt','TrunkId','ListId','findById','getMessages','FaxMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','Contacts','attachments','join','server/files/attachments','basename','CheckAfterSend'];(function(_0x502c7d,_0x2f1285){var _0x30b7ed=function(_0x2d92f3){while(--_0x2d92f3){_0x502c7d['push'](_0x502c7d['shift']());}};_0x30b7ed(++_0x2f1285);}(_0xb30a,0xd8));var _0xab30=function(_0x384621,_0x43362c){_0x384621=_0x384621-0x0;var _0x4e0bd7=_0xb30a[_0x384621];return _0x4e0bd7;};'use strict';var pdf=require(_0xab30('0x0'));var emlformat=require(_0xab30('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xab30('0x2'));var rp=require(_0xab30('0x3'));var moment=require('moment');var BPromise=require(_0xab30('0x4'));var Mustache=require('mustache');var util=require(_0xab30('0x5'));var path=require(_0xab30('0x6'));var sox=require(_0xab30('0x7'));var csv=require(_0xab30('0x8'));var ejs=require(_0xab30('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0xab30('0xa'));var crypto=require(_0xab30('0xb'));var jsforce=require(_0xab30('0xc'));var deskjs=require(_0xab30('0xd'));var toCsv=require(_0xab30('0x8'));var querystring=require(_0xab30('0xe'));var Papa=require(_0xab30('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xab30('0x10'));var as=require(_0xab30('0x11'));var hardwareService=require(_0xab30('0x12'));var logger=require(_0xab30('0x13'))(_0xab30('0x14'));var utils=require(_0xab30('0x15'));var config=require('../../config/environment');var db=require(_0xab30('0x16'))['db'];config[_0xab30('0x17')]=_[_0xab30('0x18')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xab30('0x19'))(new Redis(config['redis']));require(_0xab30('0x1a'))[_0xab30('0x1b')](socket);var jayson=require(_0xab30('0x1c'));var client=jayson[_0xab30('0x1d')][_0xab30('0x1e')]({'port':0x232c});var client9002=jayson[_0xab30('0x1d')][_0xab30('0x1e')]({'port':0x232a});function checkPasswordPattern(_0x4cbd26,_0x4dac90,_0x53d589){if(_0x53d589){var _0x4442ac=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4442ac['test'](_0x4dac90)){return _0x4cbd26;}else{throw new db[(_0xab30('0x1f'))][(_0xab30('0x20'))](_0xab30('0x21'));}}else{return _0x4cbd26;}}function respondWithRpcPromise(_0x2789be,_0x4ab226,_0x2db5ef,_0x2ae99f){return new BPromise(function(_0x146963,_0x34256d){var _0x58d550=_0x2ae99f||client;return _0x58d550[_0xab30('0x22')](_0x2789be,_0x2db5ef)[_0xab30('0x23')](function(_0x4c5b4c){logger['info'](_0xab30('0x24'),_0x4ab226,_0xab30('0x25'));logger[_0xab30('0x26')](_0xab30('0x27'),_0x4ab226,_0xab30('0x25'),JSON[_0xab30('0x28')](_0x4c5b4c));if(_0x4c5b4c[_0xab30('0x29')]){if(_0x4c5b4c[_0xab30('0x29')]['code']===0x1f4){logger[_0xab30('0x29')](_0xab30('0x24'),_0x4ab226,_0x4c5b4c[_0xab30('0x29')][_0xab30('0x2a')]);return _0x34256d(_0x4c5b4c[_0xab30('0x29')][_0xab30('0x2a')]);}logger[_0xab30('0x29')](_0xab30('0x24'),_0x4ab226,_0x4c5b4c[_0xab30('0x29')][_0xab30('0x2a')]);return _0x146963(_0x4c5b4c['error'][_0xab30('0x2a')]);}else{logger[_0xab30('0x2b')](_0xab30('0x24'),_0x4ab226,_0xab30('0x25'));_0x146963(_0x4c5b4c[_0xab30('0x2c')][_0xab30('0x2a')]);}})['catch'](function(_0x7f7655){logger[_0xab30('0x29')](_0xab30('0x24'),_0x4ab226,_0x7f7655);_0x34256d(_0x7f7655);});});}function respondWithStatusCode(_0x1f931d,_0x2fcaa4){_0x2fcaa4=_0x2fcaa4||0xcc;return function(_0x1732ce){if(_0x1732ce){return _0x1f931d[_0xab30('0x2d')](_0x2fcaa4);}return _0x1f931d['status'](_0x2fcaa4)[_0xab30('0x2e')]();};}function respondWithResult(_0x17cd59,_0x3c2b56){_0x3c2b56=_0x3c2b56||0xc8;return function(_0x41b516){if(_0x41b516){return _0x17cd59[_0xab30('0x2f')](_0x3c2b56)['json'](_0x41b516);}};}function respondWithFilteredResult(_0x429dbd,_0x2b5b13){return function(_0x28fc83){if(_0x28fc83){var _0xda32b1=_0x28fc83['count'],_0x5be258=_0x2b5b13[_0xab30('0x30')],_0x21a64e=_0x2b5b13[_0xab30('0x30')]+_0x2b5b13[_0xab30('0x31')],_0x3d7baa;if(_0x21a64e>=_0xda32b1){_0x21a64e=_0xda32b1;_0x3d7baa=0xc8;}else{_0x3d7baa=0xce;}_0x429dbd[_0xab30('0x2f')](_0x3d7baa);return _0x429dbd[_0xab30('0x32')](_0xab30('0x33'),_0x5be258+'-'+_0x21a64e+'/'+_0xda32b1)[_0xab30('0x34')](_0x28fc83);}return null;};}function patchUpdates(_0x183718){return function(_0x137f2f){try{jsonpatch[_0xab30('0x35')](_0x137f2f,_0x183718,!![]);}catch(_0x414c9b){return BPromise[_0xab30('0x36')](_0x414c9b);}return _0x137f2f[_0xab30('0x37')]();};}function saveUpdates(_0x588afd,_0x56767a){return function(_0x20dd58){if(_0x20dd58){return _0x20dd58['update'](_0x588afd)[_0xab30('0x23')](function(_0x4cbb5d){return _0x4cbb5d;});}return null;};}function removeEntity(_0x4d09c6,_0x3663af){return function(_0x5f100d){if(_0x5f100d){return _0x5f100d[_0xab30('0x38')]()['then'](function(){var _0x5033f7=_0x5f100d[_0xab30('0x39')]({'plain':!![]});var _0x48b9f1=_0xab30('0x3a');return db[_0xab30('0x3b')][_0xab30('0x38')]({'where':{'type':_0x48b9f1,'resourceId':_0x5033f7['id']}})[_0xab30('0x23')](function(){return _0x5f100d;});})[_0xab30('0x23')](function(){_0x4d09c6['status'](0xcc)[_0xab30('0x2e')]();});}};}function handleEntityNotFound(_0x38cf22,_0x37c046){return function(_0x16157f){if(!_0x16157f){_0x38cf22[_0xab30('0x2d')](0x194);}return _0x16157f;};}function handleError(_0x3b76f6,_0x2dd729){_0x2dd729=_0x2dd729||0x1f4;return function(_0x188fdf){logger[_0xab30('0x29')](_0x188fdf[_0xab30('0x3c')]);if(_0x188fdf['name']){delete _0x188fdf[_0xab30('0x3d')];}_0x3b76f6[_0xab30('0x2f')](_0x2dd729)[_0xab30('0x3e')](_0x188fdf);};}exports['index']=function(_0x103390,_0xb23363){var _0x18b2e7={'include':[{'model':db[_0xab30('0x3f')],'as':'mandatoryDispositionPause'}]},_0x2845fc={},_0xd9d9c8={'count':0x0,'rows':[]};var _0x4a8af6=_[_0xab30('0x40')](db[_0xab30('0x41')][_0xab30('0x42')],function(_0x49884a){return{'name':_0x49884a[_0xab30('0x43')],'type':_0x49884a[_0xab30('0x44')][_0xab30('0x45')]};});_0x2845fc[_0xab30('0x46')]=_[_0xab30('0x40')](_0x4a8af6,_0xab30('0x3d'));_0x2845fc[_0xab30('0x47')]=_['keys'](_0x103390[_0xab30('0x47')]);_0x2845fc['filters']=_[_0xab30('0x48')](_0x2845fc[_0xab30('0x46')],_0x2845fc[_0xab30('0x47')]);_0x18b2e7[_0xab30('0x49')]=_[_0xab30('0x48')](_0x2845fc[_0xab30('0x46')],qs['fields'](_0x103390[_0xab30('0x47')]['fields']));_0x18b2e7[_0xab30('0x49')]=_0x18b2e7[_0xab30('0x49')][_0xab30('0x4a')]?_0x18b2e7[_0xab30('0x49')]:_0x2845fc[_0xab30('0x46')];if(!_0x103390[_0xab30('0x47')]['hasOwnProperty'](_0xab30('0x4b'))){_0x18b2e7[_0xab30('0x31')]=qs[_0xab30('0x31')](_0x103390[_0xab30('0x47')][_0xab30('0x31')]);_0x18b2e7[_0xab30('0x30')]=qs[_0xab30('0x30')](_0x103390['query']['offset']);}_0x18b2e7['order']=qs[_0xab30('0x4c')](_0x103390[_0xab30('0x47')][_0xab30('0x4c')]);_0x18b2e7[_0xab30('0x4d')]=qs[_0xab30('0x4e')](_['pick'](_0x103390['query'],_0x2845fc[_0xab30('0x4e')]),_0x4a8af6);if(_0x103390[_0xab30('0x47')]['filter']){_0x18b2e7[_0xab30('0x4d')]=_[_0xab30('0x4f')](_0x18b2e7[_0xab30('0x4d')],{'$or':_['map'](_0x4a8af6,function(_0x5917ee){if(_0x5917ee['type']!==_0xab30('0x50')){var _0x39ed25={};_0x39ed25[_0x5917ee[_0xab30('0x3d')]]={'$like':'%'+_0x103390[_0xab30('0x47')][_0xab30('0x51')]+'%'};return _0x39ed25;}})});}_0x18b2e7=_['merge']({},_0x18b2e7,_0x103390[_0xab30('0x52')]);var _0x5a34b1={'where':_0x18b2e7[_0xab30('0x4d')]};return db[_0xab30('0x41')]['count'](_0x5a34b1)['then'](function(_0x58b7d8){_0xd9d9c8[_0xab30('0x53')]=_0x58b7d8;if(_0x103390['query'][_0xab30('0x54')]){_0x18b2e7['include']=[{'all':!![]}];}return db['FaxAccount'][_0xab30('0x55')](_0x18b2e7);})[_0xab30('0x23')](function(_0x293a47){_0xd9d9c8[_0xab30('0x56')]=_0x293a47;return _0xd9d9c8;})[_0xab30('0x23')](respondWithFilteredResult(_0xb23363,_0x18b2e7))['catch'](handleError(_0xb23363,null));};exports[_0xab30('0x57')]=function(_0x42c230,_0x29711e){var _0x193cba={'raw':![],'where':{'id':_0x42c230['params']['id']},'include':[{'model':db[_0xab30('0x3f')],'as':_0xab30('0x58')}]},_0x9e4d29={};_0x9e4d29[_0xab30('0x46')]=_['keys'](db[_0xab30('0x41')][_0xab30('0x42')]);_0x9e4d29['query']=_[_0xab30('0x59')](_0x42c230[_0xab30('0x47')]);_0x9e4d29[_0xab30('0x4e')]=_[_0xab30('0x48')](_0x9e4d29[_0xab30('0x46')],_0x9e4d29[_0xab30('0x47')]);_0x193cba['attributes']=_[_0xab30('0x48')](_0x9e4d29[_0xab30('0x46')],qs[_0xab30('0x5a')](_0x42c230[_0xab30('0x47')]['fields']));_0x193cba[_0xab30('0x49')]=_0x193cba[_0xab30('0x49')][_0xab30('0x4a')]?_0x193cba['attributes']:_0x9e4d29[_0xab30('0x46')];if(_0x42c230['query'][_0xab30('0x54')]){_0x193cba['include']=[{'all':!![]}];}_0x193cba=_[_0xab30('0x4f')]({},_0x193cba,_0x42c230['options']);return db[_0xab30('0x41')]['find'](_0x193cba)[_0xab30('0x23')](handleEntityNotFound(_0x29711e,null))[_0xab30('0x23')](respondWithResult(_0x29711e,null))[_0xab30('0x5b')](handleError(_0x29711e,null));};exports[_0xab30('0x5c')]=function(_0x3e2c19,_0x551182){return db[_0xab30('0x41')][_0xab30('0x5c')](_0x3e2c19[_0xab30('0x5d')],{})[_0xab30('0x23')](function(_0x41c05e){var _0x305ad1=_0x3e2c19[_0xab30('0x5e')]['get']({'plain':!![]});if(!_0x305ad1)throw new Error(_0xab30('0x5f'));if(_0x305ad1[_0xab30('0x60')]==='user'){var _0x3fd869=_0x41c05e['get']({'plain':!![]});var _0x55b0fe=_0xab30('0x3a');return db[_0xab30('0x61')][_0xab30('0x62')]({'where':{'name':_0x55b0fe,'userProfileId':_0x305ad1[_0xab30('0x63')]},'raw':!![]})[_0xab30('0x23')](function(_0x2a9bac){if(_0x2a9bac&&_0x2a9bac['autoAssociation']===0x0){return db[_0xab30('0x3b')][_0xab30('0x5c')]({'name':_0x3fd869['name'],'resourceId':_0x3fd869['id'],'type':_0x2a9bac[_0xab30('0x3d')],'sectionId':_0x2a9bac['id']},{})['then'](function(){return _0x41c05e;});}else{return _0x41c05e;}})[_0xab30('0x5b')](function(_0x5c9838){logger[_0xab30('0x29')](_0xab30('0x64'),_0x5c9838);throw _0x5c9838;});}return _0x41c05e;})[_0xab30('0x23')](respondWithResult(_0x551182,0xc9))[_0xab30('0x5b')](handleError(_0x551182,null));};exports[_0xab30('0x65')]=function(_0xf76169,_0x3a286f){if(_0xf76169[_0xab30('0x5d')]['id']){delete _0xf76169[_0xab30('0x5d')]['id'];}return db['FaxAccount'][_0xab30('0x62')]({'where':{'id':_0xf76169[_0xab30('0x66')]['id']},'include':[{'model':db['Pause'],'as':_0xab30('0x58')}]})[_0xab30('0x23')](handleEntityNotFound(_0x3a286f,null))[_0xab30('0x23')](saveUpdates(_0xf76169[_0xab30('0x5d')],null))[_0xab30('0x23')](respondWithResult(_0x3a286f,null))[_0xab30('0x5b')](handleError(_0x3a286f,null));};exports['destroy']=function(_0x50681a,_0x2a91d6){return db[_0xab30('0x41')][_0xab30('0x62')]({'where':{'id':_0x50681a['params']['id']}})['then'](handleEntityNotFound(_0x2a91d6,null))['then'](removeEntity(_0x2a91d6,null))[_0xab30('0x5b')](handleError(_0x2a91d6,null));};exports[_0xab30('0x67')]=function(_0x148543,_0x54ee39){return db['FaxAccount'][_0xab30('0x67')]()[_0xab30('0x23')](respondWithResult(_0x54ee39,null))[_0xab30('0x5b')](handleError(_0x54ee39,null));};exports[_0xab30('0x68')]=function(_0x303efa,_0x3cdba3,_0x3e5cdb){if(_0x303efa[_0xab30('0x5d')]['id']){delete _0x303efa['body']['id'];}return db[_0xab30('0x41')][_0xab30('0x62')]({'where':{'id':_0x303efa[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0x3cdba3,null))['then'](function(_0x3eed1c){if(_0x3eed1c){_0x303efa[_0xab30('0x5d')][_0xab30('0x69')]=_0x3eed1c['id'];return db[_0xab30('0x6a')][_0xab30('0x5c')](_0x303efa[_0xab30('0x5d')]);}})['then'](respondWithResult(_0x3cdba3,null))['catch'](handleError(_0x3cdba3,null));};exports[_0xab30('0x6b')]=function(_0x4b8b97,_0x2b9e95,_0x571a95){var _0x461f67={'raw':![],'where':{}};var _0x544260={};var _0x411047={'count':0x0,'rows':[]};return db[_0xab30('0x41')]['findOne']({'where':{'id':_0x4b8b97['params']['id']}})['then'](handleEntityNotFound(_0x2b9e95,null))[_0xab30('0x23')](function(_0x25db27){if(_0x25db27){_0x544260[_0xab30('0x46')]=_[_0xab30('0x59')](db[_0xab30('0x6a')]['rawAttributes']);_0x544260[_0xab30('0x47')]=_[_0xab30('0x59')](_0x4b8b97[_0xab30('0x47')]);_0x544260['filters']=_[_0xab30('0x48')](_0x544260[_0xab30('0x46')],_0x544260['query']);_0x461f67[_0xab30('0x49')]=_[_0xab30('0x48')](_0x544260[_0xab30('0x46')],qs[_0xab30('0x5a')](_0x4b8b97['query']['fields']));_0x461f67[_0xab30('0x49')]=_0x461f67['attributes']['length']?_0x461f67['attributes']:_0x544260[_0xab30('0x46')];if(!_0x4b8b97[_0xab30('0x47')]['hasOwnProperty']('nolimit')){_0x461f67['limit']=qs[_0xab30('0x31')](_0x4b8b97[_0xab30('0x47')][_0xab30('0x31')]);_0x461f67['offset']=qs[_0xab30('0x30')](_0x4b8b97['query'][_0xab30('0x30')]);}_0x461f67[_0xab30('0x6c')]=qs[_0xab30('0x4c')](_0x4b8b97[_0xab30('0x47')]['sort']);_0x461f67[_0xab30('0x4d')]=qs[_0xab30('0x4e')](_[_0xab30('0x6d')](_0x4b8b97[_0xab30('0x47')],_0x544260[_0xab30('0x4e')]));_0x461f67[_0xab30('0x4d')][_0xab30('0x69')]=_0x25db27['id'];if(_0x4b8b97['query'][_0xab30('0x51')]){_0x461f67['where']=_[_0xab30('0x4f')](_0x461f67[_0xab30('0x4d')],{'$or':_[_0xab30('0x40')](_0x461f67['attributes'],function(_0x4a4466){var _0x3398df={};_0x3398df[_0x4a4466]={'$like':'%'+_0x4b8b97[_0xab30('0x47')][_0xab30('0x51')]+'%'};return _0x3398df;})});}_0x461f67=_[_0xab30('0x4f')]({},_0x461f67,_0x4b8b97[_0xab30('0x52')]);return db[_0xab30('0x6a')]['count']({'where':_0x461f67[_0xab30('0x4d')]})['then'](function(_0x53100d){_0x411047[_0xab30('0x53')]=_0x53100d;if(_0x4b8b97[_0xab30('0x47')][_0xab30('0x54')]){_0x461f67[_0xab30('0x6e')]=[{'all':!![]}];}return db[_0xab30('0x6a')]['findAll'](_0x461f67);})['then'](function(_0x494120){_0x411047[_0xab30('0x56')]=_0x494120;return _0x411047;});}})['then'](respondWithFilteredResult(_0x2b9e95,_0x461f67))[_0xab30('0x5b')](handleError(_0x2b9e95,null));};exports[_0xab30('0x6f')]=function(_0x3d4418,_0x6a1650,_0x175329){return db[_0xab30('0x41')]['find']({'where':{'id':_0x3d4418[_0xab30('0x66')]['id']}})['then'](handleEntityNotFound(_0x6a1650,null))[_0xab30('0x23')](function(_0x1cb14b){if(_0x1cb14b){return _0x1cb14b['removeDispositions'](_0x3d4418[_0xab30('0x47')][_0xab30('0x70')]);}})['then'](respondWithStatusCode(_0x6a1650,null))[_0xab30('0x5b')](handleError(_0x6a1650,null));};exports['addAnswer']=function(_0x44a089,_0x3eb4dd,_0x47120a){if(_0x44a089[_0xab30('0x5d')]['id']){delete _0x44a089[_0xab30('0x5d')]['id'];}return db[_0xab30('0x41')][_0xab30('0x62')]({'where':{'id':_0x44a089['params']['id']}})['then'](handleEntityNotFound(_0x3eb4dd,null))['then'](function(_0x1661cb){if(_0x1661cb){_0x44a089[_0xab30('0x5d')][_0xab30('0x69')]=_0x1661cb['id'];return db[_0xab30('0x71')]['create'](_0x44a089[_0xab30('0x5d')]);}})[_0xab30('0x23')](respondWithResult(_0x3eb4dd,null))[_0xab30('0x5b')](handleError(_0x3eb4dd,null));};exports[_0xab30('0x72')]=function(_0x2a945b,_0x2d4ac0,_0x1d7c8c){var _0x193638={'raw':![],'where':{}};var _0x46bcac={};var _0x3ec44b={'count':0x0,'rows':[]};return db[_0xab30('0x41')][_0xab30('0x73')]({'where':{'id':_0x2a945b[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0x2d4ac0,null))[_0xab30('0x23')](function(_0x4969ee){if(_0x4969ee){_0x46bcac[_0xab30('0x46')]=_[_0xab30('0x59')](db['CannedAnswer']['rawAttributes']);_0x46bcac['query']=_[_0xab30('0x59')](_0x2a945b['query']);_0x46bcac['filters']=_[_0xab30('0x48')](_0x46bcac[_0xab30('0x46')],_0x46bcac[_0xab30('0x47')]);_0x193638[_0xab30('0x49')]=_[_0xab30('0x48')](_0x46bcac[_0xab30('0x46')],qs[_0xab30('0x5a')](_0x2a945b[_0xab30('0x47')][_0xab30('0x5a')]));_0x193638['attributes']=_0x193638[_0xab30('0x49')][_0xab30('0x4a')]?_0x193638[_0xab30('0x49')]:_0x46bcac[_0xab30('0x46')];if(!_0x2a945b[_0xab30('0x47')][_0xab30('0x74')](_0xab30('0x4b'))){_0x193638[_0xab30('0x31')]=qs[_0xab30('0x31')](_0x2a945b['query']['limit']);_0x193638['offset']=qs[_0xab30('0x30')](_0x2a945b[_0xab30('0x47')][_0xab30('0x30')]);}_0x193638[_0xab30('0x6c')]=qs['sort'](_0x2a945b[_0xab30('0x47')][_0xab30('0x4c')]);_0x193638['where']=qs[_0xab30('0x4e')](_[_0xab30('0x6d')](_0x2a945b[_0xab30('0x47')],_0x46bcac['filters']));_0x193638[_0xab30('0x4d')][_0xab30('0x69')]=_0x4969ee['id'];if(_0x2a945b[_0xab30('0x47')][_0xab30('0x51')]){_0x193638['where']=_[_0xab30('0x4f')](_0x193638[_0xab30('0x4d')],{'$or':_[_0xab30('0x40')](_0x193638[_0xab30('0x49')],function(_0x263867){var _0x1b0e84={};_0x1b0e84[_0x263867]={'$like':'%'+_0x2a945b[_0xab30('0x47')]['filter']+'%'};return _0x1b0e84;})});}_0x193638=_[_0xab30('0x4f')]({},_0x193638,_0x2a945b[_0xab30('0x52')]);return db[_0xab30('0x71')]['count']({'where':_0x193638['where']})[_0xab30('0x23')](function(_0x39a9ea){_0x3ec44b[_0xab30('0x53')]=_0x39a9ea;if(_0x2a945b[_0xab30('0x47')][_0xab30('0x54')]){_0x193638[_0xab30('0x6e')]=[{'all':!![]}];}return db[_0xab30('0x71')][_0xab30('0x55')](_0x193638);})['then'](function(_0x173201){_0x3ec44b[_0xab30('0x56')]=_0x173201;return _0x3ec44b;});}})['then'](respondWithFilteredResult(_0x2d4ac0,_0x193638))[_0xab30('0x5b')](handleError(_0x2d4ac0,null));};exports[_0xab30('0x75')]=function(_0x414048,_0x5bd7c3,_0xb113b){return db[_0xab30('0x41')][_0xab30('0x62')]({'where':{'id':_0x414048[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0x5bd7c3,null))['then'](function(_0x1f48c7){if(_0x1f48c7){return _0x1f48c7[_0xab30('0x75')](_0x414048[_0xab30('0x47')][_0xab30('0x70')]);}})[_0xab30('0x23')](respondWithStatusCode(_0x5bd7c3,null))[_0xab30('0x5b')](handleError(_0x5bd7c3,null));};exports[_0xab30('0x76')]=function(_0x3a9099,_0x1e911f,_0x108905){return db['FaxInteraction']['find']({'where':{'id':_0x3a9099[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0x1e911f,null))[_0xab30('0x23')](function(_0x2643a6){if(_0x2643a6){return _0x2643a6[_0xab30('0x76')](_0x3a9099['body'][_0xab30('0x70')],_['omit'](_0x3a9099[_0xab30('0x5d')],[_0xab30('0x70'),'id'])||{});}})[_0xab30('0x23')](respondWithResult(_0x1e911f,null))[_0xab30('0x5b')](handleError(_0x1e911f,null));};exports['getInteractions']=function(_0x4beb1e,_0x5bf1c5,_0x1f5d1c){var _0x35036e={'raw':![],'where':{}};var _0x1e78cc={};var _0x4af523={'count':0x0,'rows':[]};return db[_0xab30('0x41')][_0xab30('0x73')]({'where':{'id':_0x4beb1e[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0x5bf1c5,null))['then'](function(_0x977a54){if(_0x977a54){_0x1e78cc[_0xab30('0x46')]=_[_0xab30('0x59')](db[_0xab30('0x77')][_0xab30('0x42')]);_0x1e78cc[_0xab30('0x47')]=_[_0xab30('0x59')](_0x4beb1e[_0xab30('0x47')]);_0x1e78cc[_0xab30('0x4e')]=_[_0xab30('0x48')](_0x1e78cc[_0xab30('0x46')],_0x1e78cc[_0xab30('0x47')]);_0x35036e[_0xab30('0x49')]=_[_0xab30('0x48')](_0x1e78cc['model'],qs[_0xab30('0x5a')](_0x4beb1e[_0xab30('0x47')]['fields']));_0x35036e[_0xab30('0x49')]=_0x35036e[_0xab30('0x49')][_0xab30('0x4a')]?_0x35036e[_0xab30('0x49')]:_0x1e78cc['model'];if(!_0x4beb1e['query'][_0xab30('0x74')](_0xab30('0x4b'))){_0x35036e['limit']=qs[_0xab30('0x31')](_0x4beb1e['query']['limit']);_0x35036e[_0xab30('0x30')]=qs[_0xab30('0x30')](_0x4beb1e[_0xab30('0x47')][_0xab30('0x30')]);}_0x35036e[_0xab30('0x6c')]=qs[_0xab30('0x4c')](_0x4beb1e[_0xab30('0x47')]['sort']);_0x35036e['where']=qs[_0xab30('0x4e')](_[_0xab30('0x6d')](_0x4beb1e[_0xab30('0x47')],_0x1e78cc[_0xab30('0x4e')]));_0x35036e[_0xab30('0x4d')][_0xab30('0x69')]=_0x977a54['id'];if(_0x4beb1e[_0xab30('0x47')]['filter']){_0x35036e['where']=_[_0xab30('0x4f')](_0x35036e['where'],{'$or':_[_0xab30('0x40')](_0x35036e[_0xab30('0x49')],function(_0x418693){var _0x117a55={};_0x117a55[_0x418693]={'$like':'%'+_0x4beb1e[_0xab30('0x47')][_0xab30('0x51')]+'%'};return _0x117a55;})});}_0x35036e=_[_0xab30('0x4f')]({},_0x35036e,_0x4beb1e[_0xab30('0x52')]);return db[_0xab30('0x77')][_0xab30('0x53')]({'where':_0x35036e['where']})[_0xab30('0x23')](function(_0x3ee6fc){_0x4af523['count']=_0x3ee6fc;if(_0x4beb1e[_0xab30('0x47')][_0xab30('0x54')]){_0x35036e[_0xab30('0x6e')]=[{'model':db[_0xab30('0x78')],'as':_0xab30('0x79'),'required':![]},{'model':db[_0xab30('0x7a')],'as':_0xab30('0x7b'),'attributes':['name',_0xab30('0x7c'),_0xab30('0x7d')],'required':![]},{'model':db['Tag'],'as':_0xab30('0x7e'),'attributes':['id',_0xab30('0x3d'),_0xab30('0x7f')],'where':_0x4beb1e['query'][_0xab30('0x80')]?{'id':_0x4beb1e['query'][_0xab30('0x80')]}:undefined,'required':_0x4beb1e['query'][_0xab30('0x80')]?!![]:![]}];}return db[_0xab30('0x77')]['findAll'](_0x35036e);})[_0xab30('0x23')](function(_0x7c17f9){_0x4af523[_0xab30('0x56')]=_0x7c17f9;return _0x4af523;});}})[_0xab30('0x23')](respondWithFilteredResult(_0x5bf1c5,_0x35036e))[_0xab30('0x5b')](handleError(_0x5bf1c5,null));};exports[_0xab30('0x81')]=function(_0x58e25d,_0x50322b,_0x53f23d){return db['FaxAccount'][_0xab30('0x73')]({'where':{'id':_0x58e25d[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0x50322b,null))[_0xab30('0x23')](function(_0x36e436){if(_0x36e436){return db['sequelize'][_0xab30('0x82')](function(_0x166a94){return db[_0xab30('0x83')][_0xab30('0x38')]({'where':{'FaxAccountId':_0x58e25d[_0xab30('0x66')]['id']},'transaction':_0x166a94})[_0xab30('0x23')](function(_0x1f1daa){var _0x1edf9c=_[_0xab30('0x40')](_0x58e25d[_0xab30('0x5d')],function(_0x1351f6){_0x1351f6['FaxAccountId']=_0x58e25d[_0xab30('0x66')]['id'];return _0x1351f6;});return db[_0xab30('0x83')][_0xab30('0x84')](_0x1edf9c,{'transaction':_0x166a94});});})['then'](function(){return db[_0xab30('0x83')][_0xab30('0x85')]({'where':{'FaxAccountId':_0x58e25d[_0xab30('0x66')]['id']},'order':_0xab30('0x86')});});}})[_0xab30('0x23')](respondWithResult(_0x50322b,null))['catch'](handleError(_0x50322b,null));};exports[_0xab30('0x87')]=function(_0x410b8,_0xf99485,_0x2e8ed2){var _0x26d1bf={};var _0x188305={};var _0x2e12c2;var _0x2999c7;return db['FaxAccount']['findOne']({'where':{'id':_0x410b8[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0xf99485,null))[_0xab30('0x23')](function(_0x26bd66){if(_0x26bd66){_0x2e12c2=_0x26bd66;_0x188305['model']=_[_0xab30('0x59')](db[_0xab30('0x83')][_0xab30('0x42')]);_0x188305[_0xab30('0x47')]=_[_0xab30('0x59')](_0x410b8[_0xab30('0x47')]);_0x188305[_0xab30('0x4e')]=_[_0xab30('0x48')](_0x188305[_0xab30('0x46')],_0x188305[_0xab30('0x47')]);_0x26d1bf[_0xab30('0x49')]=_[_0xab30('0x48')](_0x188305[_0xab30('0x46')],qs[_0xab30('0x5a')](_0x410b8[_0xab30('0x47')][_0xab30('0x5a')]));_0x26d1bf[_0xab30('0x49')]=_0x26d1bf['attributes'][_0xab30('0x4a')]?_0x26d1bf[_0xab30('0x49')]:_0x188305['model'];_0x26d1bf[_0xab30('0x6c')]=qs[_0xab30('0x4c')](_0x410b8[_0xab30('0x47')]['sort']);_0x26d1bf[_0xab30('0x4d')]=qs['filters'](_[_0xab30('0x6d')](_0x410b8[_0xab30('0x47')],_0x188305[_0xab30('0x4e')]));if(_0x410b8[_0xab30('0x47')][_0xab30('0x51')]){_0x26d1bf[_0xab30('0x4d')]=_[_0xab30('0x4f')](_0x26d1bf[_0xab30('0x4d')],{'$or':_[_0xab30('0x40')](_0x26d1bf[_0xab30('0x49')],function(_0x46be05){var _0x271503={};_0x271503[_0x46be05]={'$like':'%'+_0x410b8[_0xab30('0x47')][_0xab30('0x51')]+'%'};return _0x271503;})});}_0x26d1bf=_[_0xab30('0x4f')]({},_0x26d1bf,_0x410b8[_0xab30('0x52')]);return _0x2e12c2['getApplications'](_0x26d1bf);}})[_0xab30('0x23')](function(_0x1ea9df){if(_0x1ea9df){_0x2999c7=_0x1ea9df[_0xab30('0x4a')];if(!_0x410b8[_0xab30('0x47')][_0xab30('0x74')](_0xab30('0x4b'))){_0x26d1bf[_0xab30('0x31')]=qs[_0xab30('0x31')](_0x410b8[_0xab30('0x47')][_0xab30('0x31')]);_0x26d1bf[_0xab30('0x30')]=qs[_0xab30('0x30')](_0x410b8[_0xab30('0x47')]['offset']);}return _0x2e12c2[_0xab30('0x87')](_0x26d1bf);}})['then'](function(_0x201130){if(_0x201130){return _0x201130?{'count':_0x2999c7,'rows':_0x201130}:null;}})['then'](respondWithResult(_0xf99485,null))[_0xab30('0x5b')](handleError(_0xf99485,null));};function Extension(_0x584161,_0x16eb3c,_0x337360,_0xd855a5){this[_0xab30('0x88')]=_0xab30('0x89');this[_0xab30('0x8a')]=_0x584161[_0xab30('0x8b')];this[_0xab30('0x8c')]=_0xd855a5;this[_0xab30('0x44')]=_0xab30('0x8d');this['description']=_0xab30('0x8e');this[_0xab30('0x69')]=_0x584161['id'];this[_0xab30('0x86')]=_0x16eb3c;this[_0xab30('0x8f')]=_0x337360;}function createExtensionsReciveFax(_0x306970){var _0x5028db=0x1;var _0x2e71a5=[];_0x2e71a5['push'](new Extension(_0x306970,_0x5028db,'',_0xab30('0x90')));_0x5028db+=0x1;_0x2e71a5[_0xab30('0x91')](new Extension(_0x306970,_0x5028db,'CDR(type)=inbound-fax',_0xab30('0x92')));_0x5028db+=0x1;for(var _0x20b21c in _0x306970){if(_0x306970[_0xab30('0x74')](_0x20b21c)&&(_0x20b21c==='ecm'||_0x20b21c===_0xab30('0x8b')||_0x20b21c===_0xab30('0x93')||_0x20b21c==='faxdetect'||_0x20b21c===_0xab30('0x94')||_0x20b21c==='maxrate'||_0x20b21c==='minrate'||_0x20b21c==='modem'||_0x20b21c===_0xab30('0x95'))){_0x2e71a5[_0xab30('0x91')](new Extension(_0x306970,_0x5028db,_0xab30('0x96')+_0x20b21c+')='+_0x306970[_0x20b21c],_0xab30('0x92')));_0x5028db+=0x1;}}_0x2e71a5[_0xab30('0x91')](new Extension(_0x306970,_0x5028db,'6',_0xab30('0x97')));_0x5028db+=0x1;_0x2e71a5['push'](new Extension(_0x306970,_0x5028db,_0xab30('0x98'),_0xab30('0x99')));_0x5028db=0x0;return _0x2e71a5;}exports[_0xab30('0x9a')]=function(_0x330a3c,_0x1429ff,_0x4820e4){var _0x1dfa16;return db[_0xab30('0x9b')][_0xab30('0x82')](function(_0x42dfb2){return db[_0xab30('0x41')][_0xab30('0x5c')](_0x330a3c[_0xab30('0x5d')],{'transaction':_0x42dfb2})[_0xab30('0x23')](function(_0xedc10d){_0x1dfa16=_0xedc10d['get']({'plain':!![]});return db[_0xab30('0x9c')][_0xab30('0x84')](createExtensionsReciveFax(_0x1dfa16),{'transaction':_0x42dfb2});});})[_0xab30('0x23')](function(){return _0x1dfa16;})[_0xab30('0x23')](respondWithResult(_0x1429ff,null))[_0xab30('0x5b')](handleError(_0x1429ff,null));};exports['updateAccountApplications']=function(_0x41a1da,_0x52dd5f,_0x3d8c00){var _0x215125;return db['sequelize'][_0xab30('0x82')](function(_0x51e2dc){return db['FaxAccount'][_0xab30('0x65')](_0x41a1da['body'],{'where':{'id':_0x41a1da[_0xab30('0x5d')]['id']},'transaction':_0x51e2dc})[_0xab30('0x23')](function(_0x23d812){return db['VoiceExtension'][_0xab30('0x38')]({'where':{'FaxAccountId':_0x41a1da[_0xab30('0x5d')]['id']},'transaction':_0x51e2dc})[_0xab30('0x23')](function(_0x124a1f){return db[_0xab30('0x9c')][_0xab30('0x84')](createExtensionsReciveFax(_[_0xab30('0x9d')](_0x41a1da[_0xab30('0x5d')],[_0xab30('0x9e'),_0xab30('0x45'),_0xab30('0x9f'),_0xab30('0xa0'),_0xab30('0xa1'),_0xab30('0xa2')])),{'transaction':_0x51e2dc});});});})[_0xab30('0x23')](function(){return db[_0xab30('0x41')][_0xab30('0xa3')](_0x41a1da[_0xab30('0x5d')]['id']);})['then'](respondWithResult(_0x52dd5f,null))[_0xab30('0x5b')](handleError(_0x52dd5f,null));};exports[_0xab30('0xa4')]=function(_0x1d39d4,_0xe47245,_0x3c6dc8){var _0x3bf203={'raw':!![],'where':{}};var _0x179dc8={};var _0x1a7f25={'count':0x0,'rows':[]};return db[_0xab30('0x41')][_0xab30('0x73')]({'where':{'id':_0x1d39d4[_0xab30('0x66')]['id']}})['then'](handleEntityNotFound(_0xe47245,null))['then'](function(_0x4a8ba8){if(_0x4a8ba8){_0x179dc8[_0xab30('0x46')]=_['keys'](db[_0xab30('0xa5')][_0xab30('0x42')]);_0x179dc8['query']=_[_0xab30('0x59')](_0x1d39d4[_0xab30('0x47')]);_0x179dc8[_0xab30('0x4e')]=_['intersection'](_0x179dc8[_0xab30('0x46')],_0x179dc8[_0xab30('0x47')]);_0x3bf203[_0xab30('0x49')]=_[_0xab30('0x48')](_0x179dc8[_0xab30('0x46')],qs[_0xab30('0x5a')](_0x1d39d4[_0xab30('0x47')][_0xab30('0x5a')]));_0x3bf203[_0xab30('0x49')]=_0x3bf203[_0xab30('0x49')][_0xab30('0x4a')]?_0x3bf203[_0xab30('0x49')]:_0x179dc8[_0xab30('0x46')];if(!_0x1d39d4[_0xab30('0x47')][_0xab30('0x74')](_0xab30('0x4b'))){_0x3bf203[_0xab30('0x31')]=qs[_0xab30('0x31')](_0x1d39d4['query'][_0xab30('0x31')]);_0x3bf203[_0xab30('0x30')]=qs['offset'](_0x1d39d4[_0xab30('0x47')][_0xab30('0x30')]);}_0x3bf203['order']=qs[_0xab30('0x4c')](_0x1d39d4[_0xab30('0x47')][_0xab30('0x4c')]);_0x3bf203[_0xab30('0x4d')]=qs[_0xab30('0x4e')](_[_0xab30('0x6d')](_0x1d39d4['query'],_0x179dc8[_0xab30('0x4e')]));_0x3bf203['where']['FaxAccountId']=_0x4a8ba8['id'];if(_0x1d39d4[_0xab30('0x47')][_0xab30('0x51')]){_0x3bf203['where']=_['merge'](_0x3bf203['where'],{'$or':_['map'](_0x3bf203[_0xab30('0x49')],function(_0x9bf77a){var _0x4ec98a={};_0x4ec98a[_0x9bf77a]={'$like':'%'+_0x1d39d4[_0xab30('0x47')]['filter']+'%'};return _0x4ec98a;})});}if(_0x1d39d4[_0xab30('0x47')][_0xab30('0xa6')]){var _0x138ee2=_0x1d39d4[_0xab30('0x47')][_0xab30('0xa6')][_0xab30('0xa7')](',');var _0xfac41e={};_0xfac41e[_0x138ee2[0x0]]={'$gte':moment(_0x138ee2[0x1])[_0xab30('0xa8')](_0xab30('0xa9'))};_0x3bf203['where']=_[_0xab30('0x4f')](_0x3bf203[_0xab30('0x4d')],_0xfac41e);}_0x3bf203=_[_0xab30('0x4f')]({},_0x3bf203,_0x1d39d4['options']);return db[_0xab30('0xa5')][_0xab30('0x53')]({'where':_0x3bf203['where']})[_0xab30('0x23')](function(_0x1d9019){_0x1a7f25['count']=_0x1d9019;if(_0x1d39d4['query'][_0xab30('0x54')]){_0x3bf203['include']=[{'all':!![]}];}return db[_0xab30('0xa5')]['findAll'](_0x3bf203);})[_0xab30('0x23')](function(_0x1920fa){_0x1a7f25[_0xab30('0x56')]=_0x1920fa;return _0x1a7f25;});}})['then'](respondWithFilteredResult(_0xe47245,_0x3bf203))[_0xab30('0x5b')](handleError(_0xe47245,null));};exports[_0xab30('0x3e')]=function(_0x4bc311,_0x2d9b34,_0x1107a1){var _0x12b120,_0x4a5993={},_0x14e391;if(_0x4bc311[_0xab30('0x5d')]['to']){_0x14e391=_0x4bc311[_0xab30('0x5d')]['to'][0x0];}return db[_0xab30('0x41')]['find']({'where':{'id':_0x4bc311[_0xab30('0x66')]['id']},'include':[{'model':db[_0xab30('0xaa')],'as':_0xab30('0xab'),'include':[{'model':db['CmContact'],'as':_0xab30('0xac'),'where':{'fax':_0x14e391},'limit':0x1,'order':[['updatedAt','DESC']]}]}]})[_0xab30('0x23')](handleEntityNotFound(_0x2d9b34,null))[_0xab30('0x23')](function(_0xad3192){_0x12b120=_0xad3192;if(_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')]&&_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][_0xab30('0x4a')]){for(var _0x32ddde=0x0;_0x32ddde<_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')]['length'];_0x32ddde+=0x1){_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][_0x32ddde]={'filename':_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][_0x32ddde][_0xab30('0x3d')],'id':_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][_0x32ddde]['id'],'path':path[_0xab30('0xae')](config['root'],_0xab30('0xaf'),_0x4bc311[_0xab30('0x5d')]['attachments'][_0x32ddde][_0xab30('0xb0')])};}}return respondWithRpcPromise('CheckAfterSend',_0xab30('0xb1'),{'FaxAccountId':_[_0xab30('0xb2')](_0x4bc311['params']['id'])?undefined:_0x4bc311[_0xab30('0x66')]['id'],'path':_[_0xab30('0xb2')](_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][0x0][_0xab30('0x6')])?undefined:_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][0x0]['path'],'fax':_[_0xab30('0xb2')](_0x4bc311[_0xab30('0x5d')]['to'][0x0])?undefined:_0x4bc311[_0xab30('0x5d')]['to'][0x0]},client9002);})[_0xab30('0x23')](function(){if(_0x12b120){if(_[_0xab30('0xb2')](_0x4bc311['body'][_0xab30('0xb3')])){_0x4bc311[_0xab30('0x5d')][_0xab30('0xb3')]=util[_0xab30('0xa8')](_0xab30('0xb4'),_0x12b120[_0xab30('0x3d')],_0x12b120[_0xab30('0xb5')]);}if(_0x12b120[_0xab30('0xab')]){if(_0x12b120['List'][_0xab30('0xac')][_0xab30('0x4a')]){return _0x12b120[_0xab30('0xab')]['Contacts'][0x0];}else{return db[_0xab30('0x78')]['create'](_[_0xab30('0x18')](_0x4bc311['body'],{'firstName':_0x4bc311[_0xab30('0x5d')]['to'][0x0],'phone':_0x4bc311[_0xab30('0x5d')]['to'][0x0],'fax':_0x4bc311[_0xab30('0x5d')]['to'][0x0],'ListId':_0x12b120['ListId']}));}}else{throw new Error(_0xab30('0xb6'));}}else{throw new Error(_0xab30('0xb7'));}})[_0xab30('0x23')](function(_0x29bf47){if(_0x29bf47){return db['FaxInteraction']['find']({'where':{'ContactId':_0x29bf47['id'],'closed':![],'FaxAccountId':_0x12b120['id']}})[_0xab30('0x23')](function(_0x3d6e3a){if(_0x3d6e3a){return[_0x3d6e3a,![]];}return db[_0xab30('0x77')][_0xab30('0x5c')]({'UserId':_0x4bc311[_0xab30('0x5e')]['id'],'ContactId':_0x29bf47['id'],'FaxAccountId':_0x12b120['id'],'fax':_0x4bc311[_0xab30('0x5d')]['to'][0x0],'firstMsgDirection':_0xab30('0xb8'),'Messages':[_['merge'](_0x4bc311['body'],{'read':![],'body':_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][0x0]['filename'],'FaxAccountId':_0x12b120['id'],'UserId':_0x4bc311[_0xab30('0x5e')]['id'],'ContactId':_0x29bf47['id'],'AttachmentId':_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][0x0]['id']})]},{'include':[{'model':db[_0xab30('0xa5')],'as':_0xab30('0xb9')}]})['then'](function(_0x341d39){return[_0x341d39,!![]];});});}else{throw new Error(_0xab30('0xba'));}})[_0xab30('0xbb')](function(_0x4f82c3,_0x445f37){if(_0x445f37){return _0x4f82c3;}return db[_0xab30('0xa5')][_0xab30('0x5c')]({'direction':_0xab30('0xb8'),'read':![],'body':_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][0x0][_0xab30('0xbc')],'FaxAccountId':_0x12b120['id'],'FaxInteractionId':_0x4f82c3['id'],'UserId':_0x4bc311[_0xab30('0x5e')]['id'],'ContactId':_0x4f82c3[_0xab30('0xbd')],'AttachmentId':_0x4bc311[_0xab30('0x5d')]['attachments'][0x0]['id']})[_0xab30('0x23')](function(_0x366345){_0x4f82c3[_0xab30('0xbe')][_0xab30('0xb9')]=[];_0x4f82c3[_0xab30('0xbe')]['Messages'][_0xab30('0x91')](_0x366345[_0xab30('0xbe')]);return _0x4f82c3;});})[_0xab30('0x23')](function(_0x3f2ca6){respondWithRpcPromise(_0xab30('0xbf'),'SendFax',{'FaxAccountId':_[_0xab30('0xb2')](_0x4bc311[_0xab30('0x66')]['id'])?undefined:_0x4bc311['params']['id'],'path':_[_0xab30('0xb2')](_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][0x0]['path'])?undefined:_0x4bc311['body']['attachments'][0x0][_0xab30('0x6')],'fax':_['isNil'](_0x4bc311[_0xab30('0x5d')]['to'][0x0])?undefined:_0x4bc311[_0xab30('0x5d')]['to'][0x0],'AttachmentId':_0x4bc311[_0xab30('0x5d')][_0xab30('0xad')][0x0]['id']},client9002)[_0xab30('0x23')](function(_0x5f782c){logger[_0xab30('0x2b')](_0xab30('0xc0'),_0x5f782c);})[_0xab30('0x5b')](function(_0x493b7a){logger[_0xab30('0x2b')](_0xab30('0xc0'),_0x493b7a);});return _0x3f2ca6;})[_0xab30('0x23')](respondWithResult(_0x2d9b34,null))[_0xab30('0x5b')](handleError(_0x2d9b34,null));};exports[_0xab30('0xc1')]=function(_0x1b3737,_0x35877f,_0x3bf821){return db[_0xab30('0x41')][_0xab30('0x62')]({'where':{'id':_0x1b3737[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0x35877f,null))[_0xab30('0x23')](function(_0x2de7a5){if(_0x2de7a5){return _0x2de7a5['addAgents'](_0x1b3737['body']['ids'],_['omit'](_0x1b3737[_0xab30('0x5d')],['ids','id'])||{})['spread'](function(_0x1ea28a){for(var _0x149c20=0x0;_0x149c20<_0x1b3737[_0xab30('0x5d')][_0xab30('0x70')][_0xab30('0x4a')];_0x149c20+=0x1){socket['emit']('userFaxAccount:save',{'UserId':_0x1b3737[_0xab30('0x5d')][_0xab30('0x70')][_0x149c20],'FaxAccountId':_0x1b3737[_0xab30('0x66')]['id']});}return _0x1ea28a;});}})[_0xab30('0x23')](respondWithResult(_0x35877f,null))['catch'](handleError(_0x35877f,null));};exports['removeAgents']=function(_0x1f7c2b,_0xfc2cf3,_0x5bf329){return db[_0xab30('0x41')][_0xab30('0x62')]({'where':{'id':_0x1f7c2b[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0xfc2cf3,null))[_0xab30('0x23')](function(_0x11883){if(_0x11883){return _0x11883[_0xab30('0xc2')](_0x1f7c2b[_0xab30('0x47')][_0xab30('0x70')])[_0xab30('0x23')](function(){if(_['isArray'](_0x1f7c2b['query'][_0xab30('0x70')])){for(var _0x5b6962=0x0;_0x5b6962<_0x1f7c2b[_0xab30('0x47')][_0xab30('0x70')]['length'];_0x5b6962+=0x1){socket['emit']('userFaxAccount:remove',{'UserId':Number(_0x1f7c2b[_0xab30('0x47')][_0xab30('0x70')][_0x5b6962]),'FaxAccountId':Number(_0x1f7c2b[_0xab30('0x66')]['id'])});}}else{socket['emit'](_0xab30('0xc3'),{'UserId':Number(_0x1f7c2b[_0xab30('0x47')]['ids']),'FaxAccountId':Number(_0x1f7c2b[_0xab30('0x66')]['id'])});}});}})[_0xab30('0x23')](respondWithStatusCode(_0xfc2cf3,null))[_0xab30('0x5b')](handleError(_0xfc2cf3,null));};exports[_0xab30('0xc4')]=function(_0x2a2328,_0x47012b,_0x5ae23d){var _0x380249={};var _0x15b8cc={};var _0x2470bd;var _0xfa49f1;return db[_0xab30('0x41')][_0xab30('0x73')]({'where':{'id':_0x2a2328[_0xab30('0x66')]['id']}})[_0xab30('0x23')](handleEntityNotFound(_0x47012b,null))[_0xab30('0x23')](function(_0x1b285e){if(_0x1b285e){_0x2470bd=_0x1b285e;_0x15b8cc[_0xab30('0x46')]=_[_0xab30('0x59')](db[_0xab30('0x7a')][_0xab30('0x42')]);_0x15b8cc['query']=_[_0xab30('0x59')](_0x2a2328[_0xab30('0x47')]);_0x15b8cc[_0xab30('0x4e')]=_['intersection'](_0x15b8cc[_0xab30('0x46')],_0x15b8cc[_0xab30('0x47')]);_0x380249['attributes']=_['intersection'](_0x15b8cc['model'],qs[_0xab30('0x5a')](_0x2a2328[_0xab30('0x47')]['fields']));_0x380249['attributes']=_0x380249[_0xab30('0x49')]['length']?_0x380249['attributes']:_0x15b8cc[_0xab30('0x46')];_0x380249[_0xab30('0x6c')]=qs[_0xab30('0x4c')](_0x2a2328['query'][_0xab30('0x4c')]);_0x380249[_0xab30('0x4d')]=qs['filters'](_[_0xab30('0x6d')](_0x2a2328[_0xab30('0x47')],_0x15b8cc['filters']));if(_0x2a2328['query'][_0xab30('0x51')]){_0x380249['where']=_['merge'](_0x380249['where'],{'$or':_[_0xab30('0x40')](_0x380249['attributes'],function(_0xd00ed5){var _0x5ad9ed={};_0x5ad9ed[_0xd00ed5]={'$like':'%'+_0x2a2328['query'][_0xab30('0x51')]+'%'};return _0x5ad9ed;})});}_0x380249=_[_0xab30('0x4f')]({},_0x380249,_0x2a2328[_0xab30('0x52')]);return _0x2470bd[_0xab30('0xc4')](_0x380249);}})[_0xab30('0x23')](function(_0x29bfc9){if(_0x29bfc9){_0xfa49f1=_0x29bfc9[_0xab30('0x4a')];if(!_0x2a2328[_0xab30('0x47')][_0xab30('0x74')](_0xab30('0x4b'))){_0x380249[_0xab30('0x31')]=qs[_0xab30('0x31')](_0x2a2328[_0xab30('0x47')][_0xab30('0x31')]);_0x380249[_0xab30('0x30')]=qs[_0xab30('0x30')](_0x2a2328[_0xab30('0x47')]['offset']);}return _0x2470bd[_0xab30('0xc4')](_0x380249);}})[_0xab30('0x23')](function(_0x2af47b){if(_0x2af47b){return _0x2af47b?{'count':_0xfa49f1,'rows':_0x2af47b}:null;}})[_0xab30('0x23')](respondWithResult(_0x47012b,null))[_0xab30('0x5b')](handleError(_0x47012b,null));};
\ No newline at end of file
+var _0xb10b=['VIRTUAL','options','FaxAccount','count','includeAll','include','findAll','rows','params','Pause','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addDisposition','FaxAccountId','Disposition','getDispositions','findOne','order','removeDispositions','ids','CannedAnswer','getAnswers','hasOwnProperty','removeAnswers','addInteraction','FaxInteraction','omit','getInteractions','nolimit','CmContact','Contact','User','fullname','internal','Tag','Tags','color','tag','sequelize','transaction','FaxApplication','bulkCreate','findAndCountAll','getApplications','context','exten','system','description','Fax\x20Extension','appdata','push','Set','ecm','localstationid','gateway','faxdetect','maxrate','minrate','modem','t38timeout','FAXOPT(','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','ReceiveFax','addAccountApplications','VoiceExtension','tech','createdAt','TrunkId','ListId','getMessages','FaxMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','updatedAt','DESC','attachments','join','server/files/attachments','basename','CheckAfterSend','isNil','Contacts','List\x20not\x20found','Send\x20Fax\x20failed','out','filename','Messages','Contact\x20not\x20found','ContactId','SendFax','SendFaxRpc,\x20%s','addAgents','spread','emit','removeAgents','isArray','userFaxAccount:remove','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','register','jayson/promise','client','http','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','status','end','json','offset','limit','set','Content-Range','apply','save','update','destroy','get','FaxAccounts','UserProfileResource','stack','name','send','mandatoryDispositionPause','map','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','sort','where','pick','filter','merge'];(function(_0x1a36a5,_0x746928){var _0x746243=function(_0x481966){while(--_0x481966){_0x1a36a5['push'](_0x1a36a5['shift']());}};_0x746243(++_0x746928);}(_0xb10b,0x12a));var _0xbb10=function(_0x6ab30c,_0x2c713b){_0x6ab30c=_0x6ab30c-0x0;var _0x36e953=_0xb10b[_0x6ab30c];return _0x36e953;};'use strict';var emlformat=require(_0xbb10('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbb10('0x1'));var jsonpatch=require(_0xbb10('0x2'));var rp=require(_0xbb10('0x3'));var moment=require('moment');var BPromise=require(_0xbb10('0x4'));var Mustache=require(_0xbb10('0x5'));var util=require(_0xbb10('0x6'));var path=require(_0xbb10('0x7'));var sox=require(_0xbb10('0x8'));var csv=require(_0xbb10('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xbb10('0xa'));var _=require(_0xbb10('0xb'));var squel=require('squel');var crypto=require(_0xbb10('0xc'));var jsforce=require(_0xbb10('0xd'));var deskjs=require(_0xbb10('0xe'));var toCsv=require(_0xbb10('0x9'));var querystring=require(_0xbb10('0xf'));var Papa=require(_0xbb10('0x10'));var Redis=require(_0xbb10('0x11'));var authService=require(_0xbb10('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbb10('0x13'));var logger=require(_0xbb10('0x14'))(_0xbb10('0x15'));var utils=require('../../config/utils');var config=require(_0xbb10('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xbb10('0x17'))['db'];config[_0xbb10('0x18')]=_[_0xbb10('0x19')](config[_0xbb10('0x18')],{'host':_0xbb10('0x1a'),'port':0x18eb});var socket=require(_0xbb10('0x1b'))(new Redis(config['redis']));require(_0xbb10('0x1c'))[_0xbb10('0x1d')](socket);var jayson=require(_0xbb10('0x1e'));var client=jayson[_0xbb10('0x1f')][_0xbb10('0x20')]({'port':0x232c});var client9002=jayson[_0xbb10('0x1f')][_0xbb10('0x20')]({'port':0x232a});function respondWithRpcPromise(_0x36b5e8,_0x3e26f4,_0x2b184e,_0x4a2bfc){return new BPromise(function(_0x2eca0f,_0x1145f1){var _0x133ac2=_0x4a2bfc||client;return _0x133ac2[_0xbb10('0x21')](_0x36b5e8,_0x2b184e)[_0xbb10('0x22')](function(_0x1682a4){logger[_0xbb10('0x23')](_0xbb10('0x24'),_0x3e26f4,_0xbb10('0x25'));logger[_0xbb10('0x26')]('FaxAccount,\x20%s,\x20%s,\x20%s',_0x3e26f4,_0xbb10('0x25'),JSON[_0xbb10('0x27')](_0x1682a4));if(_0x1682a4[_0xbb10('0x28')]){if(_0x1682a4[_0xbb10('0x28')][_0xbb10('0x29')]===0x1f4){logger[_0xbb10('0x28')]('FaxAccount,\x20%s,\x20%s',_0x3e26f4,_0x1682a4[_0xbb10('0x28')][_0xbb10('0x2a')]);return _0x1145f1(_0x1682a4['error']['message']);}logger[_0xbb10('0x28')](_0xbb10('0x24'),_0x3e26f4,_0x1682a4[_0xbb10('0x28')][_0xbb10('0x2a')]);return _0x2eca0f(_0x1682a4[_0xbb10('0x28')][_0xbb10('0x2a')]);}else{logger[_0xbb10('0x23')](_0xbb10('0x24'),_0x3e26f4,_0xbb10('0x25'));_0x2eca0f(_0x1682a4[_0xbb10('0x2b')][_0xbb10('0x2a')]);}})[_0xbb10('0x2c')](function(_0x537898){logger['error']('FaxAccount,\x20%s,\x20%s',_0x3e26f4,_0x537898);_0x1145f1(_0x537898);});});}function respondWithStatusCode(_0xc93a04,_0x3c5ae7){_0x3c5ae7=_0x3c5ae7||0xcc;return function(_0x2c89b9){if(_0x2c89b9){return _0xc93a04['sendStatus'](_0x3c5ae7);}return _0xc93a04[_0xbb10('0x2d')](_0x3c5ae7)[_0xbb10('0x2e')]();};}function respondWithResult(_0x6ed43b,_0x1d5e95){_0x1d5e95=_0x1d5e95||0xc8;return function(_0x1acce9){if(_0x1acce9){return _0x6ed43b[_0xbb10('0x2d')](_0x1d5e95)[_0xbb10('0x2f')](_0x1acce9);}};}function respondWithFilteredResult(_0x4aabb9,_0x3796c7){return function(_0x21ac54){if(_0x21ac54){var _0xfc3595=_0x21ac54['count'],_0x2e0249=_0x3796c7[_0xbb10('0x30')],_0x1d30aa=_0x3796c7['offset']+_0x3796c7[_0xbb10('0x31')],_0x2ff4c1;if(_0x1d30aa>=_0xfc3595){_0x1d30aa=_0xfc3595;_0x2ff4c1=0xc8;}else{_0x2ff4c1=0xce;}_0x4aabb9['status'](_0x2ff4c1);return _0x4aabb9[_0xbb10('0x32')](_0xbb10('0x33'),_0x2e0249+'-'+_0x1d30aa+'/'+_0xfc3595)[_0xbb10('0x2f')](_0x21ac54);}return null;};}function patchUpdates(_0x491db4){return function(_0x518d47){try{jsonpatch[_0xbb10('0x34')](_0x518d47,_0x491db4,!![]);}catch(_0x34f65e){return BPromise['reject'](_0x34f65e);}return _0x518d47[_0xbb10('0x35')]();};}function saveUpdates(_0x37dde7,_0x2f653f){return function(_0x1c0b57){if(_0x1c0b57){return _0x1c0b57[_0xbb10('0x36')](_0x37dde7)[_0xbb10('0x22')](function(_0xf85197){return _0xf85197;});}return null;};}function removeEntity(_0x4975f5,_0x25acb3){return function(_0x1da9c9){if(_0x1da9c9){return _0x1da9c9[_0xbb10('0x37')]()[_0xbb10('0x22')](function(){var _0xfb2c5e=_0x1da9c9[_0xbb10('0x38')]({'plain':!![]});var _0x188cbd=_0xbb10('0x39');return db[_0xbb10('0x3a')]['destroy']({'where':{'type':_0x188cbd,'resourceId':_0xfb2c5e['id']}})[_0xbb10('0x22')](function(){return _0x1da9c9;});})[_0xbb10('0x22')](function(){_0x4975f5[_0xbb10('0x2d')](0xcc)[_0xbb10('0x2e')]();});}};}function handleEntityNotFound(_0x570f5a,_0x111762){return function(_0x5de37b){if(!_0x5de37b){_0x570f5a['sendStatus'](0x194);}return _0x5de37b;};}function handleError(_0x3eb3cc,_0x40c164){_0x40c164=_0x40c164||0x1f4;return function(_0x26e76a){logger[_0xbb10('0x28')](_0x26e76a[_0xbb10('0x3b')]);if(_0x26e76a[_0xbb10('0x3c')]){delete _0x26e76a['name'];}_0x3eb3cc[_0xbb10('0x2d')](_0x40c164)[_0xbb10('0x3d')](_0x26e76a);};}exports['index']=function(_0x5e3fbd,_0x5cd55f){var _0x31bee3={'include':[{'model':db['Pause'],'as':_0xbb10('0x3e')}]},_0x2b0b45={},_0x2b658a={'count':0x0,'rows':[]};var _0x3e8538=_[_0xbb10('0x3f')](db['FaxAccount'][_0xbb10('0x40')],function(_0x12238a){return{'name':_0x12238a[_0xbb10('0x41')],'type':_0x12238a[_0xbb10('0x42')]['key']};});_0x2b0b45[_0xbb10('0x43')]=_[_0xbb10('0x3f')](_0x3e8538,'name');_0x2b0b45[_0xbb10('0x44')]=_[_0xbb10('0x45')](_0x5e3fbd[_0xbb10('0x44')]);_0x2b0b45[_0xbb10('0x46')]=_[_0xbb10('0x47')](_0x2b0b45[_0xbb10('0x43')],_0x2b0b45['query']);_0x31bee3[_0xbb10('0x48')]=_[_0xbb10('0x47')](_0x2b0b45[_0xbb10('0x43')],qs[_0xbb10('0x49')](_0x5e3fbd['query'][_0xbb10('0x49')]));_0x31bee3[_0xbb10('0x48')]=_0x31bee3[_0xbb10('0x48')][_0xbb10('0x4a')]?_0x31bee3['attributes']:_0x2b0b45[_0xbb10('0x43')];if(!_0x5e3fbd[_0xbb10('0x44')]['hasOwnProperty']('nolimit')){_0x31bee3[_0xbb10('0x31')]=qs['limit'](_0x5e3fbd[_0xbb10('0x44')][_0xbb10('0x31')]);_0x31bee3['offset']=qs[_0xbb10('0x30')](_0x5e3fbd[_0xbb10('0x44')][_0xbb10('0x30')]);}_0x31bee3['order']=qs[_0xbb10('0x4b')](_0x5e3fbd[_0xbb10('0x44')][_0xbb10('0x4b')]);_0x31bee3[_0xbb10('0x4c')]=qs[_0xbb10('0x46')](_[_0xbb10('0x4d')](_0x5e3fbd[_0xbb10('0x44')],_0x2b0b45[_0xbb10('0x46')]),_0x3e8538);if(_0x5e3fbd[_0xbb10('0x44')][_0xbb10('0x4e')]){_0x31bee3[_0xbb10('0x4c')]=_[_0xbb10('0x4f')](_0x31bee3['where'],{'$or':_[_0xbb10('0x3f')](_0x3e8538,function(_0x41bbf8){if(_0x41bbf8['type']!==_0xbb10('0x50')){var _0x2f5027={};_0x2f5027[_0x41bbf8[_0xbb10('0x3c')]]={'$like':'%'+_0x5e3fbd[_0xbb10('0x44')][_0xbb10('0x4e')]+'%'};return _0x2f5027;}})});}_0x31bee3=_[_0xbb10('0x4f')]({},_0x31bee3,_0x5e3fbd[_0xbb10('0x51')]);var _0x5be85e={'where':_0x31bee3['where']};return db[_0xbb10('0x52')][_0xbb10('0x53')](_0x5be85e)[_0xbb10('0x22')](function(_0x57d2c0){_0x2b658a['count']=_0x57d2c0;if(_0x5e3fbd[_0xbb10('0x44')][_0xbb10('0x54')]){_0x31bee3[_0xbb10('0x55')]=[{'all':!![]}];}return db[_0xbb10('0x52')][_0xbb10('0x56')](_0x31bee3);})[_0xbb10('0x22')](function(_0x2f2552){_0x2b658a[_0xbb10('0x57')]=_0x2f2552;return _0x2b658a;})[_0xbb10('0x22')](respondWithFilteredResult(_0x5cd55f,_0x31bee3))[_0xbb10('0x2c')](handleError(_0x5cd55f,null));};exports['show']=function(_0x5eafac,_0x412e13){var _0x467dba={'raw':![],'where':{'id':_0x5eafac[_0xbb10('0x58')]['id']},'include':[{'model':db[_0xbb10('0x59')],'as':_0xbb10('0x3e')}]},_0x36ab7d={};_0x36ab7d[_0xbb10('0x43')]=_[_0xbb10('0x45')](db[_0xbb10('0x52')][_0xbb10('0x40')]);_0x36ab7d[_0xbb10('0x44')]=_[_0xbb10('0x45')](_0x5eafac[_0xbb10('0x44')]);_0x36ab7d[_0xbb10('0x46')]=_[_0xbb10('0x47')](_0x36ab7d['model'],_0x36ab7d[_0xbb10('0x44')]);_0x467dba['attributes']=_[_0xbb10('0x47')](_0x36ab7d[_0xbb10('0x43')],qs[_0xbb10('0x49')](_0x5eafac[_0xbb10('0x44')][_0xbb10('0x49')]));_0x467dba[_0xbb10('0x48')]=_0x467dba[_0xbb10('0x48')][_0xbb10('0x4a')]?_0x467dba[_0xbb10('0x48')]:_0x36ab7d[_0xbb10('0x43')];if(_0x5eafac[_0xbb10('0x44')][_0xbb10('0x54')]){_0x467dba[_0xbb10('0x55')]=[{'all':!![]}];}_0x467dba=_[_0xbb10('0x4f')]({},_0x467dba,_0x5eafac[_0xbb10('0x51')]);return db['FaxAccount'][_0xbb10('0x5a')](_0x467dba)[_0xbb10('0x22')](handleEntityNotFound(_0x412e13,null))[_0xbb10('0x22')](respondWithResult(_0x412e13,null))[_0xbb10('0x2c')](handleError(_0x412e13,null));};exports[_0xbb10('0x5b')]=function(_0x379d8c,_0x4bedd0){return db[_0xbb10('0x52')][_0xbb10('0x5b')](_0x379d8c[_0xbb10('0x5c')],{})[_0xbb10('0x22')](function(_0x432728){var _0x22de7f=_0x379d8c[_0xbb10('0x5d')][_0xbb10('0x38')]({'plain':!![]});if(!_0x22de7f)throw new Error(_0xbb10('0x5e'));if(_0x22de7f[_0xbb10('0x5f')]===_0xbb10('0x5d')){var _0x2a1ce1=_0x432728[_0xbb10('0x38')]({'plain':!![]});var _0x4e7fac='FaxAccounts';return db[_0xbb10('0x60')][_0xbb10('0x5a')]({'where':{'name':_0x4e7fac,'userProfileId':_0x22de7f[_0xbb10('0x61')]},'raw':!![]})[_0xbb10('0x22')](function(_0x5573bb){if(_0x5573bb&&_0x5573bb['autoAssociation']===0x0){return db[_0xbb10('0x3a')][_0xbb10('0x5b')]({'name':_0x2a1ce1[_0xbb10('0x3c')],'resourceId':_0x2a1ce1['id'],'type':_0x5573bb[_0xbb10('0x3c')],'sectionId':_0x5573bb['id']},{})[_0xbb10('0x22')](function(){return _0x432728;});}else{return _0x432728;}})[_0xbb10('0x2c')](function(_0x45c0dc){logger['error'](_0xbb10('0x62'),_0x45c0dc);throw _0x45c0dc;});}return _0x432728;})[_0xbb10('0x22')](respondWithResult(_0x4bedd0,0xc9))['catch'](handleError(_0x4bedd0,null));};exports['update']=function(_0x5a231f,_0x32c1e8){if(_0x5a231f[_0xbb10('0x5c')]['id']){delete _0x5a231f[_0xbb10('0x5c')]['id'];}return db['FaxAccount']['find']({'where':{'id':_0x5a231f['params']['id']},'include':[{'model':db[_0xbb10('0x59')],'as':_0xbb10('0x3e')}]})[_0xbb10('0x22')](handleEntityNotFound(_0x32c1e8,null))['then'](saveUpdates(_0x5a231f[_0xbb10('0x5c')],null))[_0xbb10('0x22')](respondWithResult(_0x32c1e8,null))['catch'](handleError(_0x32c1e8,null));};exports['destroy']=function(_0x27d7b9,_0x308896){return db[_0xbb10('0x52')][_0xbb10('0x5a')]({'where':{'id':_0x27d7b9['params']['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x308896,null))[_0xbb10('0x22')](removeEntity(_0x308896,null))[_0xbb10('0x2c')](handleError(_0x308896,null));};exports['describe']=function(_0x402a01,_0x2f05bc){return db[_0xbb10('0x52')]['describe']()[_0xbb10('0x22')](respondWithResult(_0x2f05bc,null))[_0xbb10('0x2c')](handleError(_0x2f05bc,null));};exports[_0xbb10('0x63')]=function(_0x37b65f,_0x5e4a6e,_0x251417){if(_0x37b65f[_0xbb10('0x5c')]['id']){delete _0x37b65f[_0xbb10('0x5c')]['id'];}return db[_0xbb10('0x52')]['find']({'where':{'id':_0x37b65f[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x5e4a6e,null))[_0xbb10('0x22')](function(_0x2ceb3e){if(_0x2ceb3e){_0x37b65f[_0xbb10('0x5c')][_0xbb10('0x64')]=_0x2ceb3e['id'];return db[_0xbb10('0x65')]['create'](_0x37b65f['body']);}})['then'](respondWithResult(_0x5e4a6e,null))[_0xbb10('0x2c')](handleError(_0x5e4a6e,null));};exports[_0xbb10('0x66')]=function(_0x3eda96,_0x5c9afc,_0x5cd089){var _0x46f462={'raw':![],'where':{}};var _0x1b11c0={};var _0xd9e743={'count':0x0,'rows':[]};return db[_0xbb10('0x52')][_0xbb10('0x67')]({'where':{'id':_0x3eda96[_0xbb10('0x58')]['id']}})['then'](handleEntityNotFound(_0x5c9afc,null))[_0xbb10('0x22')](function(_0x15fae2){if(_0x15fae2){_0x1b11c0[_0xbb10('0x43')]=_[_0xbb10('0x45')](db[_0xbb10('0x65')]['rawAttributes']);_0x1b11c0['query']=_['keys'](_0x3eda96[_0xbb10('0x44')]);_0x1b11c0[_0xbb10('0x46')]=_[_0xbb10('0x47')](_0x1b11c0[_0xbb10('0x43')],_0x1b11c0[_0xbb10('0x44')]);_0x46f462[_0xbb10('0x48')]=_['intersection'](_0x1b11c0[_0xbb10('0x43')],qs['fields'](_0x3eda96['query']['fields']));_0x46f462[_0xbb10('0x48')]=_0x46f462[_0xbb10('0x48')][_0xbb10('0x4a')]?_0x46f462[_0xbb10('0x48')]:_0x1b11c0['model'];if(!_0x3eda96[_0xbb10('0x44')]['hasOwnProperty']('nolimit')){_0x46f462[_0xbb10('0x31')]=qs[_0xbb10('0x31')](_0x3eda96[_0xbb10('0x44')][_0xbb10('0x31')]);_0x46f462[_0xbb10('0x30')]=qs['offset'](_0x3eda96[_0xbb10('0x44')][_0xbb10('0x30')]);}_0x46f462[_0xbb10('0x68')]=qs[_0xbb10('0x4b')](_0x3eda96[_0xbb10('0x44')][_0xbb10('0x4b')]);_0x46f462[_0xbb10('0x4c')]=qs['filters'](_[_0xbb10('0x4d')](_0x3eda96[_0xbb10('0x44')],_0x1b11c0[_0xbb10('0x46')]));_0x46f462[_0xbb10('0x4c')][_0xbb10('0x64')]=_0x15fae2['id'];if(_0x3eda96[_0xbb10('0x44')][_0xbb10('0x4e')]){_0x46f462[_0xbb10('0x4c')]=_['merge'](_0x46f462[_0xbb10('0x4c')],{'$or':_[_0xbb10('0x3f')](_0x46f462[_0xbb10('0x48')],function(_0x56416a){var _0x4ee101={};_0x4ee101[_0x56416a]={'$like':'%'+_0x3eda96['query'][_0xbb10('0x4e')]+'%'};return _0x4ee101;})});}_0x46f462=_['merge']({},_0x46f462,_0x3eda96['options']);return db[_0xbb10('0x65')][_0xbb10('0x53')]({'where':_0x46f462[_0xbb10('0x4c')]})[_0xbb10('0x22')](function(_0x32ec27){_0xd9e743[_0xbb10('0x53')]=_0x32ec27;if(_0x3eda96[_0xbb10('0x44')][_0xbb10('0x54')]){_0x46f462[_0xbb10('0x55')]=[{'all':!![]}];}return db['Disposition'][_0xbb10('0x56')](_0x46f462);})[_0xbb10('0x22')](function(_0x46b6d2){_0xd9e743[_0xbb10('0x57')]=_0x46b6d2;return _0xd9e743;});}})['then'](respondWithFilteredResult(_0x5c9afc,_0x46f462))['catch'](handleError(_0x5c9afc,null));};exports[_0xbb10('0x69')]=function(_0x2280bd,_0x30f0a4,_0x32bb25){return db['FaxAccount'][_0xbb10('0x5a')]({'where':{'id':_0x2280bd[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x30f0a4,null))[_0xbb10('0x22')](function(_0x35c1e8){if(_0x35c1e8){return _0x35c1e8['removeDispositions'](_0x2280bd['query'][_0xbb10('0x6a')]);}})[_0xbb10('0x22')](respondWithStatusCode(_0x30f0a4,null))[_0xbb10('0x2c')](handleError(_0x30f0a4,null));};exports['addAnswer']=function(_0x256b35,_0x13e2ab,_0x50bcc9){if(_0x256b35['body']['id']){delete _0x256b35[_0xbb10('0x5c')]['id'];}return db[_0xbb10('0x52')][_0xbb10('0x5a')]({'where':{'id':_0x256b35['params']['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x13e2ab,null))[_0xbb10('0x22')](function(_0xfbb365){if(_0xfbb365){_0x256b35[_0xbb10('0x5c')][_0xbb10('0x64')]=_0xfbb365['id'];return db[_0xbb10('0x6b')][_0xbb10('0x5b')](_0x256b35[_0xbb10('0x5c')]);}})[_0xbb10('0x22')](respondWithResult(_0x13e2ab,null))['catch'](handleError(_0x13e2ab,null));};exports[_0xbb10('0x6c')]=function(_0x28cc46,_0x412fbf,_0xdb7d3e){var _0x3e3083={'raw':![],'where':{}};var _0x39f64b={};var _0x33a6fc={'count':0x0,'rows':[]};return db[_0xbb10('0x52')][_0xbb10('0x67')]({'where':{'id':_0x28cc46[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x412fbf,null))[_0xbb10('0x22')](function(_0x59e985){if(_0x59e985){_0x39f64b['model']=_[_0xbb10('0x45')](db[_0xbb10('0x6b')][_0xbb10('0x40')]);_0x39f64b[_0xbb10('0x44')]=_[_0xbb10('0x45')](_0x28cc46['query']);_0x39f64b[_0xbb10('0x46')]=_[_0xbb10('0x47')](_0x39f64b[_0xbb10('0x43')],_0x39f64b[_0xbb10('0x44')]);_0x3e3083[_0xbb10('0x48')]=_[_0xbb10('0x47')](_0x39f64b['model'],qs[_0xbb10('0x49')](_0x28cc46[_0xbb10('0x44')]['fields']));_0x3e3083[_0xbb10('0x48')]=_0x3e3083['attributes'][_0xbb10('0x4a')]?_0x3e3083[_0xbb10('0x48')]:_0x39f64b[_0xbb10('0x43')];if(!_0x28cc46[_0xbb10('0x44')][_0xbb10('0x6d')]('nolimit')){_0x3e3083[_0xbb10('0x31')]=qs['limit'](_0x28cc46[_0xbb10('0x44')][_0xbb10('0x31')]);_0x3e3083['offset']=qs['offset'](_0x28cc46[_0xbb10('0x44')][_0xbb10('0x30')]);}_0x3e3083[_0xbb10('0x68')]=qs[_0xbb10('0x4b')](_0x28cc46[_0xbb10('0x44')][_0xbb10('0x4b')]);_0x3e3083[_0xbb10('0x4c')]=qs[_0xbb10('0x46')](_[_0xbb10('0x4d')](_0x28cc46[_0xbb10('0x44')],_0x39f64b[_0xbb10('0x46')]));_0x3e3083['where'][_0xbb10('0x64')]=_0x59e985['id'];if(_0x28cc46[_0xbb10('0x44')][_0xbb10('0x4e')]){_0x3e3083[_0xbb10('0x4c')]=_[_0xbb10('0x4f')](_0x3e3083[_0xbb10('0x4c')],{'$or':_[_0xbb10('0x3f')](_0x3e3083[_0xbb10('0x48')],function(_0x3e6fe2){var _0x18a136={};_0x18a136[_0x3e6fe2]={'$like':'%'+_0x28cc46[_0xbb10('0x44')][_0xbb10('0x4e')]+'%'};return _0x18a136;})});}_0x3e3083=_['merge']({},_0x3e3083,_0x28cc46[_0xbb10('0x51')]);return db['CannedAnswer'][_0xbb10('0x53')]({'where':_0x3e3083[_0xbb10('0x4c')]})[_0xbb10('0x22')](function(_0x40236c){_0x33a6fc[_0xbb10('0x53')]=_0x40236c;if(_0x28cc46['query'][_0xbb10('0x54')]){_0x3e3083[_0xbb10('0x55')]=[{'all':!![]}];}return db[_0xbb10('0x6b')][_0xbb10('0x56')](_0x3e3083);})[_0xbb10('0x22')](function(_0x41380b){_0x33a6fc['rows']=_0x41380b;return _0x33a6fc;});}})['then'](respondWithFilteredResult(_0x412fbf,_0x3e3083))[_0xbb10('0x2c')](handleError(_0x412fbf,null));};exports[_0xbb10('0x6e')]=function(_0x41d4d0,_0x57d5a1,_0x124b32){return db[_0xbb10('0x52')]['find']({'where':{'id':_0x41d4d0[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x57d5a1,null))['then'](function(_0xdd3c7e){if(_0xdd3c7e){return _0xdd3c7e['removeAnswers'](_0x41d4d0[_0xbb10('0x44')][_0xbb10('0x6a')]);}})['then'](respondWithStatusCode(_0x57d5a1,null))[_0xbb10('0x2c')](handleError(_0x57d5a1,null));};exports[_0xbb10('0x6f')]=function(_0x4bac29,_0x5dae56,_0xea6bf2){return db[_0xbb10('0x70')][_0xbb10('0x5a')]({'where':{'id':_0x4bac29[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x5dae56,null))['then'](function(_0xe7c0a3){if(_0xe7c0a3){return _0xe7c0a3[_0xbb10('0x6f')](_0x4bac29[_0xbb10('0x5c')]['ids'],_[_0xbb10('0x71')](_0x4bac29[_0xbb10('0x5c')],[_0xbb10('0x6a'),'id'])||{});}})[_0xbb10('0x22')](respondWithResult(_0x5dae56,null))[_0xbb10('0x2c')](handleError(_0x5dae56,null));};exports[_0xbb10('0x72')]=function(_0x1f55d3,_0x189f07,_0x2010d4){var _0x5f1fcd={'raw':![],'where':{}};var _0x4fc544={};var _0x37e40c={'count':0x0,'rows':[]};return db[_0xbb10('0x52')][_0xbb10('0x67')]({'where':{'id':_0x1f55d3[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x189f07,null))[_0xbb10('0x22')](function(_0x1cccec){if(_0x1cccec){_0x4fc544[_0xbb10('0x43')]=_[_0xbb10('0x45')](db[_0xbb10('0x70')][_0xbb10('0x40')]);_0x4fc544[_0xbb10('0x44')]=_[_0xbb10('0x45')](_0x1f55d3['query']);_0x4fc544[_0xbb10('0x46')]=_[_0xbb10('0x47')](_0x4fc544[_0xbb10('0x43')],_0x4fc544[_0xbb10('0x44')]);_0x5f1fcd[_0xbb10('0x48')]=_[_0xbb10('0x47')](_0x4fc544[_0xbb10('0x43')],qs[_0xbb10('0x49')](_0x1f55d3[_0xbb10('0x44')][_0xbb10('0x49')]));_0x5f1fcd[_0xbb10('0x48')]=_0x5f1fcd['attributes'][_0xbb10('0x4a')]?_0x5f1fcd['attributes']:_0x4fc544[_0xbb10('0x43')];if(!_0x1f55d3[_0xbb10('0x44')][_0xbb10('0x6d')](_0xbb10('0x73'))){_0x5f1fcd[_0xbb10('0x31')]=qs[_0xbb10('0x31')](_0x1f55d3['query'][_0xbb10('0x31')]);_0x5f1fcd['offset']=qs[_0xbb10('0x30')](_0x1f55d3[_0xbb10('0x44')][_0xbb10('0x30')]);}_0x5f1fcd[_0xbb10('0x68')]=qs[_0xbb10('0x4b')](_0x1f55d3[_0xbb10('0x44')][_0xbb10('0x4b')]);_0x5f1fcd[_0xbb10('0x4c')]=qs[_0xbb10('0x46')](_[_0xbb10('0x4d')](_0x1f55d3[_0xbb10('0x44')],_0x4fc544[_0xbb10('0x46')]));_0x5f1fcd['where'][_0xbb10('0x64')]=_0x1cccec['id'];if(_0x1f55d3['query'][_0xbb10('0x4e')]){_0x5f1fcd[_0xbb10('0x4c')]=_[_0xbb10('0x4f')](_0x5f1fcd[_0xbb10('0x4c')],{'$or':_[_0xbb10('0x3f')](_0x5f1fcd[_0xbb10('0x48')],function(_0x185ec9){var _0x5e9888={};_0x5e9888[_0x185ec9]={'$like':'%'+_0x1f55d3[_0xbb10('0x44')]['filter']+'%'};return _0x5e9888;})});}_0x5f1fcd=_['merge']({},_0x5f1fcd,_0x1f55d3[_0xbb10('0x51')]);return db[_0xbb10('0x70')][_0xbb10('0x53')]({'where':_0x5f1fcd[_0xbb10('0x4c')]})[_0xbb10('0x22')](function(_0x16b8c1){_0x37e40c['count']=_0x16b8c1;if(_0x1f55d3[_0xbb10('0x44')][_0xbb10('0x54')]){_0x5f1fcd[_0xbb10('0x55')]=[{'model':db[_0xbb10('0x74')],'as':_0xbb10('0x75'),'required':![]},{'model':db[_0xbb10('0x76')],'as':'Owner','attributes':[_0xbb10('0x3c'),_0xbb10('0x77'),_0xbb10('0x78')],'required':![]},{'model':db[_0xbb10('0x79')],'as':_0xbb10('0x7a'),'attributes':['id',_0xbb10('0x3c'),_0xbb10('0x7b')],'where':_0x1f55d3['query'][_0xbb10('0x7c')]?{'id':_0x1f55d3['query'][_0xbb10('0x7c')]}:undefined,'required':_0x1f55d3['query']['tag']?!![]:![]}];}return db[_0xbb10('0x70')][_0xbb10('0x56')](_0x5f1fcd);})[_0xbb10('0x22')](function(_0x3b7552){_0x37e40c[_0xbb10('0x57')]=_0x3b7552;return _0x37e40c;});}})['then'](respondWithFilteredResult(_0x189f07,_0x5f1fcd))[_0xbb10('0x2c')](handleError(_0x189f07,null));};exports['addApplications']=function(_0x4b877c,_0x4dd138,_0xa00798){return db[_0xbb10('0x52')][_0xbb10('0x67')]({'where':{'id':_0x4b877c[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x4dd138,null))['then'](function(_0x125bcf){if(_0x125bcf){return db[_0xbb10('0x7d')][_0xbb10('0x7e')](function(_0x1bd1c1){return db[_0xbb10('0x7f')][_0xbb10('0x37')]({'where':{'FaxAccountId':_0x4b877c[_0xbb10('0x58')]['id']},'transaction':_0x1bd1c1})['then'](function(_0x4c95c2){var _0x584a62=_[_0xbb10('0x3f')](_0x4b877c[_0xbb10('0x5c')],function(_0x2ae3c6){_0x2ae3c6[_0xbb10('0x64')]=_0x4b877c[_0xbb10('0x58')]['id'];return _0x2ae3c6;});return db[_0xbb10('0x7f')][_0xbb10('0x80')](_0x584a62,{'transaction':_0x1bd1c1});});})[_0xbb10('0x22')](function(){return db[_0xbb10('0x7f')][_0xbb10('0x81')]({'where':{'FaxAccountId':_0x4b877c['params']['id']},'order':'priority'});});}})['then'](respondWithResult(_0x4dd138,null))[_0xbb10('0x2c')](handleError(_0x4dd138,null));};exports[_0xbb10('0x82')]=function(_0x7984c1,_0x47c820,_0x2bfa8e){var _0x2f6be3={};var _0x2c638d={};var _0x290280;var _0x2a6589;return db[_0xbb10('0x52')]['findOne']({'where':{'id':_0x7984c1['params']['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x47c820,null))['then'](function(_0x370215){if(_0x370215){_0x290280=_0x370215;_0x2c638d[_0xbb10('0x43')]=_[_0xbb10('0x45')](db[_0xbb10('0x7f')][_0xbb10('0x40')]);_0x2c638d[_0xbb10('0x44')]=_[_0xbb10('0x45')](_0x7984c1[_0xbb10('0x44')]);_0x2c638d[_0xbb10('0x46')]=_[_0xbb10('0x47')](_0x2c638d['model'],_0x2c638d[_0xbb10('0x44')]);_0x2f6be3['attributes']=_[_0xbb10('0x47')](_0x2c638d['model'],qs[_0xbb10('0x49')](_0x7984c1[_0xbb10('0x44')][_0xbb10('0x49')]));_0x2f6be3[_0xbb10('0x48')]=_0x2f6be3['attributes'][_0xbb10('0x4a')]?_0x2f6be3['attributes']:_0x2c638d[_0xbb10('0x43')];_0x2f6be3[_0xbb10('0x68')]=qs[_0xbb10('0x4b')](_0x7984c1['query'][_0xbb10('0x4b')]);_0x2f6be3[_0xbb10('0x4c')]=qs[_0xbb10('0x46')](_[_0xbb10('0x4d')](_0x7984c1[_0xbb10('0x44')],_0x2c638d[_0xbb10('0x46')]));if(_0x7984c1['query']['filter']){_0x2f6be3['where']=_[_0xbb10('0x4f')](_0x2f6be3['where'],{'$or':_[_0xbb10('0x3f')](_0x2f6be3['attributes'],function(_0xf90506){var _0x34ce1b={};_0x34ce1b[_0xf90506]={'$like':'%'+_0x7984c1[_0xbb10('0x44')]['filter']+'%'};return _0x34ce1b;})});}_0x2f6be3=_['merge']({},_0x2f6be3,_0x7984c1[_0xbb10('0x51')]);return _0x290280[_0xbb10('0x82')](_0x2f6be3);}})[_0xbb10('0x22')](function(_0x59b20f){if(_0x59b20f){_0x2a6589=_0x59b20f[_0xbb10('0x4a')];if(!_0x7984c1[_0xbb10('0x44')][_0xbb10('0x6d')]('nolimit')){_0x2f6be3['limit']=qs['limit'](_0x7984c1[_0xbb10('0x44')]['limit']);_0x2f6be3[_0xbb10('0x30')]=qs[_0xbb10('0x30')](_0x7984c1[_0xbb10('0x44')][_0xbb10('0x30')]);}return _0x290280[_0xbb10('0x82')](_0x2f6be3);}})[_0xbb10('0x22')](function(_0x14fce6){if(_0x14fce6){return _0x14fce6?{'count':_0x2a6589,'rows':_0x14fce6}:null;}})[_0xbb10('0x22')](respondWithResult(_0x47c820,null))[_0xbb10('0x2c')](handleError(_0x47c820,null));};function Extension(_0x431792,_0x2e2710,_0x4e33b6,_0xaa2353){this[_0xbb10('0x83')]='from-voip-provider';this[_0xbb10('0x84')]=_0x431792['localstationid'];this['app']=_0xaa2353;this[_0xbb10('0x42')]=_0xbb10('0x85');this[_0xbb10('0x86')]=_0xbb10('0x87');this[_0xbb10('0x64')]=_0x431792['id'];this['priority']=_0x2e2710;this[_0xbb10('0x88')]=_0x4e33b6;}function createExtensionsReciveFax(_0x18b749){var _0x4f17c1=0x1;var _0xa45726=[];_0xa45726[_0xbb10('0x89')](new Extension(_0x18b749,_0x4f17c1,'','Answer'));_0x4f17c1+=0x1;_0xa45726[_0xbb10('0x89')](new Extension(_0x18b749,_0x4f17c1,'CDR(type)=inbound-fax',_0xbb10('0x8a')));_0x4f17c1+=0x1;for(var _0x8e8049 in _0x18b749){if(_0x18b749[_0xbb10('0x6d')](_0x8e8049)&&(_0x8e8049===_0xbb10('0x8b')||_0x8e8049===_0xbb10('0x8c')||_0x8e8049===_0xbb10('0x8d')||_0x8e8049===_0xbb10('0x8e')||_0x8e8049==='headerinfo'||_0x8e8049===_0xbb10('0x8f')||_0x8e8049===_0xbb10('0x90')||_0x8e8049===_0xbb10('0x91')||_0x8e8049===_0xbb10('0x92'))){_0xa45726[_0xbb10('0x89')](new Extension(_0x18b749,_0x4f17c1,_0xbb10('0x93')+_0x8e8049+')='+_0x18b749[_0x8e8049],'Set'));_0x4f17c1+=0x1;}}_0xa45726['push'](new Extension(_0x18b749,_0x4f17c1,'6','Wait'));_0x4f17c1+=0x1;_0xa45726[_0xbb10('0x89')](new Extension(_0x18b749,_0x4f17c1,_0xbb10('0x94'),_0xbb10('0x95')));_0x4f17c1=0x0;return _0xa45726;}exports[_0xbb10('0x96')]=function(_0x57700b,_0x3b01a3,_0x3d7b4d){var _0x468e26;return db['sequelize']['transaction'](function(_0xe5b08){return db['FaxAccount'][_0xbb10('0x5b')](_0x57700b[_0xbb10('0x5c')],{'transaction':_0xe5b08})[_0xbb10('0x22')](function(_0x42276f){_0x468e26=_0x42276f[_0xbb10('0x38')]({'plain':!![]});return db[_0xbb10('0x97')][_0xbb10('0x80')](createExtensionsReciveFax(_0x468e26),{'transaction':_0xe5b08});});})['then'](function(){return _0x468e26;})[_0xbb10('0x22')](respondWithResult(_0x3b01a3,null))[_0xbb10('0x2c')](handleError(_0x3b01a3,null));};exports['updateAccountApplications']=function(_0x23301a,_0x2ab7dc,_0x32f261){var _0x5b11a2;return db['sequelize']['transaction'](function(_0x3571ba){return db[_0xbb10('0x52')]['update'](_0x23301a[_0xbb10('0x5c')],{'where':{'id':_0x23301a[_0xbb10('0x5c')]['id']},'transaction':_0x3571ba})[_0xbb10('0x22')](function(_0x24b0ea){return db[_0xbb10('0x97')][_0xbb10('0x37')]({'where':{'FaxAccountId':_0x23301a[_0xbb10('0x5c')]['id']},'transaction':_0x3571ba})['then'](function(_0x304603){return db['VoiceExtension']['bulkCreate'](createExtensionsReciveFax(_['omit'](_0x23301a[_0xbb10('0x5c')],[_0xbb10('0x98'),'key',_0xbb10('0x99'),'updatedAt',_0xbb10('0x9a'),_0xbb10('0x9b')])),{'transaction':_0x3571ba});});});})[_0xbb10('0x22')](function(){return db['FaxAccount']['findById'](_0x23301a[_0xbb10('0x5c')]['id']);})['then'](respondWithResult(_0x2ab7dc,null))[_0xbb10('0x2c')](handleError(_0x2ab7dc,null));};exports[_0xbb10('0x9c')]=function(_0x589ecb,_0x50cd00,_0xe844b0){var _0x385bab={'raw':!![],'where':{}};var _0x30e1dd={};var _0x59eaaf={'count':0x0,'rows':[]};return db[_0xbb10('0x52')][_0xbb10('0x67')]({'where':{'id':_0x589ecb[_0xbb10('0x58')]['id']}})['then'](handleEntityNotFound(_0x50cd00,null))[_0xbb10('0x22')](function(_0x203e5a){if(_0x203e5a){_0x30e1dd[_0xbb10('0x43')]=_[_0xbb10('0x45')](db[_0xbb10('0x9d')][_0xbb10('0x40')]);_0x30e1dd[_0xbb10('0x44')]=_[_0xbb10('0x45')](_0x589ecb[_0xbb10('0x44')]);_0x30e1dd[_0xbb10('0x46')]=_[_0xbb10('0x47')](_0x30e1dd[_0xbb10('0x43')],_0x30e1dd[_0xbb10('0x44')]);_0x385bab['attributes']=_['intersection'](_0x30e1dd[_0xbb10('0x43')],qs['fields'](_0x589ecb[_0xbb10('0x44')][_0xbb10('0x49')]));_0x385bab[_0xbb10('0x48')]=_0x385bab['attributes'][_0xbb10('0x4a')]?_0x385bab[_0xbb10('0x48')]:_0x30e1dd[_0xbb10('0x43')];if(!_0x589ecb[_0xbb10('0x44')][_0xbb10('0x6d')]('nolimit')){_0x385bab[_0xbb10('0x31')]=qs[_0xbb10('0x31')](_0x589ecb[_0xbb10('0x44')][_0xbb10('0x31')]);_0x385bab[_0xbb10('0x30')]=qs[_0xbb10('0x30')](_0x589ecb['query'][_0xbb10('0x30')]);}_0x385bab[_0xbb10('0x68')]=qs['sort'](_0x589ecb[_0xbb10('0x44')][_0xbb10('0x4b')]);_0x385bab[_0xbb10('0x4c')]=qs[_0xbb10('0x46')](_[_0xbb10('0x4d')](_0x589ecb[_0xbb10('0x44')],_0x30e1dd[_0xbb10('0x46')]));_0x385bab[_0xbb10('0x4c')][_0xbb10('0x64')]=_0x203e5a['id'];if(_0x589ecb[_0xbb10('0x44')][_0xbb10('0x4e')]){_0x385bab[_0xbb10('0x4c')]=_[_0xbb10('0x4f')](_0x385bab[_0xbb10('0x4c')],{'$or':_[_0xbb10('0x3f')](_0x385bab['attributes'],function(_0x12e6cb){var _0x6b5fb3={};_0x6b5fb3[_0x12e6cb]={'$like':'%'+_0x589ecb['query']['filter']+'%'};return _0x6b5fb3;})});}if(_0x589ecb[_0xbb10('0x44')][_0xbb10('0x9e')]){var _0x24810b=_0x589ecb[_0xbb10('0x44')][_0xbb10('0x9e')][_0xbb10('0x9f')](',');var _0x3a696f={};_0x3a696f[_0x24810b[0x0]]={'$gte':moment(_0x24810b[0x1])[_0xbb10('0xa0')](_0xbb10('0xa1'))};_0x385bab['where']=_['merge'](_0x385bab['where'],_0x3a696f);}_0x385bab=_['merge']({},_0x385bab,_0x589ecb['options']);return db['FaxMessage'][_0xbb10('0x53')]({'where':_0x385bab[_0xbb10('0x4c')]})[_0xbb10('0x22')](function(_0x395ac8){_0x59eaaf['count']=_0x395ac8;if(_0x589ecb[_0xbb10('0x44')][_0xbb10('0x54')]){_0x385bab[_0xbb10('0x55')]=[{'all':!![]}];}return db[_0xbb10('0x9d')]['findAll'](_0x385bab);})['then'](function(_0x3057b4){_0x59eaaf[_0xbb10('0x57')]=_0x3057b4;return _0x59eaaf;});}})['then'](respondWithFilteredResult(_0x50cd00,_0x385bab))['catch'](handleError(_0x50cd00,null));};exports[_0xbb10('0x3d')]=function(_0xf1371a,_0x3706b5,_0x3bbdff){var _0x18cda3,_0x564dc6={},_0x4744f4;if(_0xf1371a['body']['to']){_0x4744f4=_0xf1371a['body']['to'][0x0];}return db[_0xbb10('0x52')][_0xbb10('0x5a')]({'where':{'id':_0xf1371a[_0xbb10('0x58')]['id']},'include':[{'model':db[_0xbb10('0xa2')],'as':_0xbb10('0xa3'),'include':[{'model':db[_0xbb10('0x74')],'as':'Contacts','where':{'fax':_0x4744f4},'limit':0x1,'order':[[_0xbb10('0xa4'),_0xbb10('0xa5')]]}]}]})[_0xbb10('0x22')](handleEntityNotFound(_0x3706b5,null))[_0xbb10('0x22')](function(_0x6f8d2){_0x18cda3=_0x6f8d2;if(_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')]&&_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][_0xbb10('0x4a')]){for(var _0xbae19c=0x0;_0xbae19c<_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][_0xbb10('0x4a')];_0xbae19c+=0x1){_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][_0xbae19c]={'filename':_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][_0xbae19c][_0xbb10('0x3c')],'id':_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][_0xbae19c]['id'],'path':path[_0xbb10('0xa7')](config['root'],_0xbb10('0xa8'),_0xf1371a['body'][_0xbb10('0xa6')][_0xbae19c][_0xbb10('0xa9')])};}}return respondWithRpcPromise(_0xbb10('0xaa'),_0xbb10('0xaa'),{'FaxAccountId':_[_0xbb10('0xab')](_0xf1371a['params']['id'])?undefined:_0xf1371a['params']['id'],'path':_['isNil'](_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][0x0]['path'])?undefined:_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][0x0][_0xbb10('0x7')],'fax':_['isNil'](_0xf1371a[_0xbb10('0x5c')]['to'][0x0])?undefined:_0xf1371a[_0xbb10('0x5c')]['to'][0x0]},client9002);})[_0xbb10('0x22')](function(){if(_0x18cda3){if(_['isNil'](_0xf1371a[_0xbb10('0x5c')]['from'])){_0xf1371a[_0xbb10('0x5c')]['from']=util['format']('\x22%s\x22\x20<%s>',_0x18cda3['name'],_0x18cda3['fax']);}if(_0x18cda3['List']){if(_0x18cda3[_0xbb10('0xa3')][_0xbb10('0xac')][_0xbb10('0x4a')]){return _0x18cda3[_0xbb10('0xa3')]['Contacts'][0x0];}else{return db[_0xbb10('0x74')][_0xbb10('0x5b')](_[_0xbb10('0x19')](_0xf1371a[_0xbb10('0x5c')],{'firstName':_0xf1371a[_0xbb10('0x5c')]['to'][0x0],'phone':_0xf1371a[_0xbb10('0x5c')]['to'][0x0],'fax':_0xf1371a[_0xbb10('0x5c')]['to'][0x0],'ListId':_0x18cda3[_0xbb10('0x9b')]}));}}else{throw new Error(_0xbb10('0xad'));}}else{throw new Error(_0xbb10('0xae'));}})['then'](function(_0x1e4ed3){if(_0x1e4ed3){return db[_0xbb10('0x70')][_0xbb10('0x5a')]({'where':{'ContactId':_0x1e4ed3['id'],'closed':![],'FaxAccountId':_0x18cda3['id']}})['then'](function(_0x873cc9){if(_0x873cc9){return[_0x873cc9,![]];}return db[_0xbb10('0x70')][_0xbb10('0x5b')]({'UserId':_0xf1371a[_0xbb10('0x5d')]['id'],'ContactId':_0x1e4ed3['id'],'FaxAccountId':_0x18cda3['id'],'fax':_0xf1371a['body']['to'][0x0],'firstMsgDirection':_0xbb10('0xaf'),'Messages':[_[_0xbb10('0x4f')](_0xf1371a[_0xbb10('0x5c')],{'read':![],'body':_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][0x0][_0xbb10('0xb0')],'FaxAccountId':_0x18cda3['id'],'UserId':_0xf1371a[_0xbb10('0x5d')]['id'],'ContactId':_0x1e4ed3['id'],'AttachmentId':_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][0x0]['id']})]},{'include':[{'model':db[_0xbb10('0x9d')],'as':_0xbb10('0xb1')}]})['then'](function(_0x59d917){return[_0x59d917,!![]];});});}else{throw new Error(_0xbb10('0xb2'));}})['spread'](function(_0x5eb1fb,_0x8c5e76){if(_0x8c5e76){return _0x5eb1fb;}return db[_0xbb10('0x9d')]['create']({'direction':_0xbb10('0xaf'),'read':![],'body':_0xf1371a[_0xbb10('0x5c')]['attachments'][0x0][_0xbb10('0xb0')],'FaxAccountId':_0x18cda3['id'],'FaxInteractionId':_0x5eb1fb['id'],'UserId':_0xf1371a[_0xbb10('0x5d')]['id'],'ContactId':_0x5eb1fb[_0xbb10('0xb3')],'AttachmentId':_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][0x0]['id']})['then'](function(_0x4fc260){_0x5eb1fb['dataValues'][_0xbb10('0xb1')]=[];_0x5eb1fb['dataValues'][_0xbb10('0xb1')]['push'](_0x4fc260['dataValues']);return _0x5eb1fb;});})[_0xbb10('0x22')](function(_0x43168d){respondWithRpcPromise(_0xbb10('0xb4'),_0xbb10('0xb4'),{'FaxAccountId':_[_0xbb10('0xab')](_0xf1371a[_0xbb10('0x58')]['id'])?undefined:_0xf1371a['params']['id'],'path':_['isNil'](_0xf1371a['body'][_0xbb10('0xa6')][0x0][_0xbb10('0x7')])?undefined:_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][0x0][_0xbb10('0x7')],'fax':_[_0xbb10('0xab')](_0xf1371a[_0xbb10('0x5c')]['to'][0x0])?undefined:_0xf1371a['body']['to'][0x0],'AttachmentId':_0xf1371a[_0xbb10('0x5c')][_0xbb10('0xa6')][0x0]['id']},client9002)[_0xbb10('0x22')](function(_0x84a51c){logger['info'](_0xbb10('0xb5'),_0x84a51c);})['catch'](function(_0x4fc743){logger[_0xbb10('0x23')](_0xbb10('0xb5'),_0x4fc743);});return _0x43168d;})[_0xbb10('0x22')](respondWithResult(_0x3706b5,null))[_0xbb10('0x2c')](handleError(_0x3706b5,null));};exports[_0xbb10('0xb6')]=function(_0x422774,_0x4b7bf8,_0x39fdd3){return db[_0xbb10('0x52')][_0xbb10('0x5a')]({'where':{'id':_0x422774[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x4b7bf8,null))[_0xbb10('0x22')](function(_0x19a629){if(_0x19a629){return _0x19a629['addAgents'](_0x422774[_0xbb10('0x5c')][_0xbb10('0x6a')],_[_0xbb10('0x71')](_0x422774['body'],['ids','id'])||{})[_0xbb10('0xb7')](function(_0xf07094){for(var _0x3b007e=0x0;_0x3b007e<_0x422774[_0xbb10('0x5c')][_0xbb10('0x6a')][_0xbb10('0x4a')];_0x3b007e+=0x1){socket[_0xbb10('0xb8')]('userFaxAccount:save',{'UserId':_0x422774[_0xbb10('0x5c')][_0xbb10('0x6a')][_0x3b007e],'FaxAccountId':_0x422774[_0xbb10('0x58')]['id']});}return _0xf07094;});}})['then'](respondWithResult(_0x4b7bf8,null))['catch'](handleError(_0x4b7bf8,null));};exports['removeAgents']=function(_0x4a01cd,_0x2f73e0,_0x3479ef){return db[_0xbb10('0x52')][_0xbb10('0x5a')]({'where':{'id':_0x4a01cd['params']['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x2f73e0,null))['then'](function(_0x1f071e){if(_0x1f071e){return _0x1f071e[_0xbb10('0xb9')](_0x4a01cd[_0xbb10('0x44')][_0xbb10('0x6a')])[_0xbb10('0x22')](function(){if(_[_0xbb10('0xba')](_0x4a01cd[_0xbb10('0x44')][_0xbb10('0x6a')])){for(var _0x243dc2=0x0;_0x243dc2<_0x4a01cd[_0xbb10('0x44')][_0xbb10('0x6a')][_0xbb10('0x4a')];_0x243dc2+=0x1){socket['emit'](_0xbb10('0xbb'),{'UserId':Number(_0x4a01cd[_0xbb10('0x44')][_0xbb10('0x6a')][_0x243dc2]),'FaxAccountId':Number(_0x4a01cd['params']['id'])});}}else{socket[_0xbb10('0xb8')]('userFaxAccount:remove',{'UserId':Number(_0x4a01cd[_0xbb10('0x44')][_0xbb10('0x6a')]),'FaxAccountId':Number(_0x4a01cd[_0xbb10('0x58')]['id'])});}});}})[_0xbb10('0x22')](respondWithStatusCode(_0x2f73e0,null))[_0xbb10('0x2c')](handleError(_0x2f73e0,null));};exports['getAgents']=function(_0x5345df,_0x842d94,_0x4cf5cc){var _0x553bb8={};var _0x2ff72a={};var _0x5621b1;var _0xa9ed32;return db[_0xbb10('0x52')][_0xbb10('0x67')]({'where':{'id':_0x5345df[_0xbb10('0x58')]['id']}})[_0xbb10('0x22')](handleEntityNotFound(_0x842d94,null))[_0xbb10('0x22')](function(_0x3a0940){if(_0x3a0940){_0x5621b1=_0x3a0940;_0x2ff72a[_0xbb10('0x43')]=_['keys'](db[_0xbb10('0x76')]['rawAttributes']);_0x2ff72a[_0xbb10('0x44')]=_['keys'](_0x5345df[_0xbb10('0x44')]);_0x2ff72a[_0xbb10('0x46')]=_['intersection'](_0x2ff72a[_0xbb10('0x43')],_0x2ff72a[_0xbb10('0x44')]);_0x553bb8[_0xbb10('0x48')]=_['intersection'](_0x2ff72a[_0xbb10('0x43')],qs[_0xbb10('0x49')](_0x5345df[_0xbb10('0x44')]['fields']));_0x553bb8[_0xbb10('0x48')]=_0x553bb8[_0xbb10('0x48')][_0xbb10('0x4a')]?_0x553bb8['attributes']:_0x2ff72a[_0xbb10('0x43')];_0x553bb8['order']=qs[_0xbb10('0x4b')](_0x5345df[_0xbb10('0x44')][_0xbb10('0x4b')]);_0x553bb8[_0xbb10('0x4c')]=qs[_0xbb10('0x46')](_[_0xbb10('0x4d')](_0x5345df[_0xbb10('0x44')],_0x2ff72a[_0xbb10('0x46')]));if(_0x5345df[_0xbb10('0x44')][_0xbb10('0x4e')]){_0x553bb8['where']=_['merge'](_0x553bb8[_0xbb10('0x4c')],{'$or':_[_0xbb10('0x3f')](_0x553bb8[_0xbb10('0x48')],function(_0x50ea2a){var _0x3d5870={};_0x3d5870[_0x50ea2a]={'$like':'%'+_0x5345df[_0xbb10('0x44')][_0xbb10('0x4e')]+'%'};return _0x3d5870;})});}_0x553bb8=_[_0xbb10('0x4f')]({},_0x553bb8,_0x5345df[_0xbb10('0x51')]);return _0x5621b1[_0xbb10('0xbc')](_0x553bb8);}})[_0xbb10('0x22')](function(_0x2035e1){if(_0x2035e1){_0xa9ed32=_0x2035e1[_0xbb10('0x4a')];if(!_0x5345df['query'][_0xbb10('0x6d')](_0xbb10('0x73'))){_0x553bb8[_0xbb10('0x31')]=qs[_0xbb10('0x31')](_0x5345df['query'][_0xbb10('0x31')]);_0x553bb8[_0xbb10('0x30')]=qs[_0xbb10('0x30')](_0x5345df['query']['offset']);}return _0x5621b1[_0xbb10('0xbc')](_0x553bb8);}})['then'](function(_0x37c688){if(_0x37c688){return _0x37c688?{'count':_0xa9ed32,'rows':_0x37c688}:null;}})['then'](respondWithResult(_0x842d94,null))[_0xbb10('0x2c')](handleError(_0x842d94,null));};
\ No newline at end of file