Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index 2389978..1c49db5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x213b=['createdAt','updatedAt','ListId','findById','getMessages','FaxMessage','$gte','split','YYYY-MM-DD\x20HH:mm:ss','Contacts','DESC','attachments','join','root','server/files/attachments','basename','CheckAfterSend','isNil','from','format','List','List\x20not\x20found','user','out','Messages','Contact\x20not\x20found','spread','filename','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','omit','emit','removeAgents','isArray','userFaxAccount:remove','getAgents','User','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','jayson/promise','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','destroy','get','FaxAccounts','UserProfileResource','stack','name','send','index','Pause','mandatoryDispositionPause','map','FaxAccount','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','where','VIRTUAL','merge','options','includeAll','include','rows','catch','show','params','find','create','body','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','FaxAccountId','Disposition','findOne','rawAttributes','order','sort','pick','filter','findAll','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','addInteraction','FaxInteraction','getInteractions','CmContact','Contact','Owner','internal','Tag','Tags','color','tag','addApplications','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','FaxApplication','bulkCreate','findAndCountAll','finally','getApplications','context','exten','localstationid','app','system','description','Fax\x20Extension','priority','appdata','push','CDR(type)=inbound-fax','Set','gateway','headerinfo','minrate','t38timeout','FAXOPT(','Wait','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','ReceiveFax','addAccountApplications','VoiceExtension','updateAccountApplications'];(function(_0x2efe05,_0x5c5cab){var _0xae733e=function(_0x29c473){while(--_0x29c473){_0x2efe05['push'](_0x2efe05['shift']());}};_0xae733e(++_0x5c5cab);}(_0x213b,0x1b5));var _0xb213=function(_0x23eae1,_0x170b2e){_0x23eae1=_0x23eae1-0x0;var _0x4d8438=_0x213b[_0x23eae1];return _0x4d8438;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb213('0x0'));var zipdir=require(_0xb213('0x1'));var jsonpatch=require(_0xb213('0x2'));var rp=require(_0xb213('0x3'));var moment=require(_0xb213('0x4'));var BPromise=require(_0xb213('0x5'));var Mustache=require('mustache');var util=require(_0xb213('0x6'));var path=require(_0xb213('0x7'));var sox=require('sox');var csv=require(_0xb213('0x8'));var ejs=require(_0xb213('0x9'));var fs=require('fs');var fs_extra=require(_0xb213('0xa'));var _=require(_0xb213('0xb'));var squel=require(_0xb213('0xc'));var crypto=require(_0xb213('0xd'));var jsforce=require(_0xb213('0xe'));var deskjs=require(_0xb213('0xf'));var toCsv=require('to-csv');var querystring=require(_0xb213('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xb213('0x11'));var hardwareService=require(_0xb213('0x12'));var logger=require(_0xb213('0x13'))(_0xb213('0x14'));var utils=require(_0xb213('0x15'));var config=require(_0xb213('0x16'));var licenseUtil=require(_0xb213('0x17'));var db=require(_0xb213('0x18'))['db'];config[_0xb213('0x19')]=_[_0xb213('0x1a')](config[_0xb213('0x19')],{'host':_0xb213('0x1b'),'port':0x18eb});var socket=require(_0xb213('0x1c'))(new Redis(config['redis']));require('./faxAccount.socket')[_0xb213('0x1d')](socket);var jayson=require(_0xb213('0x1e'));var client=jayson['client']['http']({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x1a2a93,_0x3e9c14,_0x5d12bf,_0x40c452){return new BPromise(function(_0x58b21b,_0x201e1c){var _0x162c5b=_0x40c452||client;return _0x162c5b[_0xb213('0x1f')](_0x1a2a93,_0x5d12bf)[_0xb213('0x20')](function(_0x31ef02){logger[_0xb213('0x21')](_0xb213('0x22'),_0x3e9c14,_0xb213('0x23'));logger[_0xb213('0x24')](_0xb213('0x25'),_0x3e9c14,_0xb213('0x23'),JSON[_0xb213('0x26')](_0x31ef02));if(_0x31ef02[_0xb213('0x27')]){if(_0x31ef02[_0xb213('0x27')][_0xb213('0x28')]===0x1f4){logger[_0xb213('0x27')](_0xb213('0x22'),_0x3e9c14,_0x31ef02[_0xb213('0x27')][_0xb213('0x29')]);return _0x201e1c(_0x31ef02[_0xb213('0x27')][_0xb213('0x29')]);}logger[_0xb213('0x27')](_0xb213('0x22'),_0x3e9c14,_0x31ef02[_0xb213('0x27')][_0xb213('0x29')]);return _0x58b21b(_0x31ef02['error']['message']);}else{logger[_0xb213('0x21')](_0xb213('0x22'),_0x3e9c14,_0xb213('0x23'));_0x58b21b(_0x31ef02[_0xb213('0x2a')][_0xb213('0x29')]);}})['catch'](function(_0x1b4538){logger[_0xb213('0x27')](_0xb213('0x22'),_0x3e9c14,_0x1b4538);_0x201e1c(_0x1b4538);});});}function respondWithStatusCode(_0x3a30f4,_0x10bcf1){_0x10bcf1=_0x10bcf1||0xcc;return function(_0x2a8e3b){if(_0x2a8e3b){return _0x3a30f4[_0xb213('0x2b')](_0x10bcf1);}return _0x3a30f4[_0xb213('0x2c')](_0x10bcf1)[_0xb213('0x2d')]();};}function respondWithResult(_0xc0090b,_0x59bdf9){_0x59bdf9=_0x59bdf9||0xc8;return function(_0x2db756){if(_0x2db756){return _0xc0090b['status'](_0x59bdf9)[_0xb213('0x2e')](_0x2db756);}};}function respondWithFilteredResult(_0x3e2c86,_0x452027){return function(_0x8f8c35){if(_0x8f8c35){var _0x1d8358=typeof _0x452027[_0xb213('0x2f')]===_0xb213('0x30')&&typeof _0x452027[_0xb213('0x31')]===_0xb213('0x30');var _0x59b95f=_0x8f8c35[_0xb213('0x32')];var _0x3b1e26=_0x1d8358?0x0:_0x452027[_0xb213('0x2f')];var _0x46dc25=_0x1d8358?_0x8f8c35[_0xb213('0x32')]:_0x452027[_0xb213('0x2f')]+_0x452027[_0xb213('0x31')];var _0x4bf37f;if(_0x46dc25>=_0x59b95f){_0x46dc25=_0x59b95f;_0x4bf37f=0xc8;}else{_0x4bf37f=0xce;}_0x3e2c86[_0xb213('0x2c')](_0x4bf37f);return _0x3e2c86[_0xb213('0x33')](_0xb213('0x34'),_0x3b1e26+'-'+_0x46dc25+'/'+_0x59b95f)['json'](_0x8f8c35);}return null;};}function patchUpdates(_0x4bca68){return function(_0x3ca431){try{jsonpatch['apply'](_0x3ca431,_0x4bca68,!![]);}catch(_0x5949c7){return BPromise[_0xb213('0x35')](_0x5949c7);}return _0x3ca431[_0xb213('0x36')]();};}function saveUpdates(_0x2df2d,_0x131329){return function(_0x2c24f3){if(_0x2c24f3){return _0x2c24f3[_0xb213('0x37')](_0x2df2d)[_0xb213('0x20')](function(_0x4098e3){return _0x4098e3;});}return null;};}function removeEntity(_0x487895,_0x1af175){return function(_0x938dbc){if(_0x938dbc){return _0x938dbc[_0xb213('0x38')]()['then'](function(){var _0x29fd44=_0x938dbc[_0xb213('0x39')]({'plain':!![]});var _0x5b31d5=_0xb213('0x3a');return db[_0xb213('0x3b')]['destroy']({'where':{'type':_0x5b31d5,'resourceId':_0x29fd44['id']}})[_0xb213('0x20')](function(){return _0x938dbc;});})[_0xb213('0x20')](function(){_0x487895['status'](0xcc)[_0xb213('0x2d')]();});}};}function handleEntityNotFound(_0x724c9c,_0x3d7853){return function(_0xa83525){if(!_0xa83525){_0x724c9c[_0xb213('0x2b')](0x194);}return _0xa83525;};}function handleError(_0x350500,_0x3f3a02){_0x3f3a02=_0x3f3a02||0x1f4;return function(_0xb60a75){logger[_0xb213('0x27')](_0xb60a75[_0xb213('0x3c')]);if(_0xb60a75[_0xb213('0x3d')]){delete _0xb60a75[_0xb213('0x3d')];}_0x350500[_0xb213('0x2c')](_0x3f3a02)[_0xb213('0x3e')](_0xb60a75);};}exports[_0xb213('0x3f')]=function(_0x4c092d,_0xe9840e){var _0x1cd1f6={'include':[{'model':db[_0xb213('0x40')],'as':_0xb213('0x41')}]},_0x2cd091={},_0x531521={'count':0x0,'rows':[]};var _0x15d73d=_[_0xb213('0x42')](db[_0xb213('0x43')]['rawAttributes'],function(_0x4f6d79){return{'name':_0x4f6d79[_0xb213('0x44')],'type':_0x4f6d79[_0xb213('0x45')][_0xb213('0x46')]};});_0x2cd091[_0xb213('0x47')]=_['map'](_0x15d73d,_0xb213('0x3d'));_0x2cd091[_0xb213('0x48')]=_[_0xb213('0x49')](_0x4c092d[_0xb213('0x48')]);_0x2cd091[_0xb213('0x4a')]=_[_0xb213('0x4b')](_0x2cd091[_0xb213('0x47')],_0x2cd091['query']);_0x1cd1f6[_0xb213('0x4c')]=_[_0xb213('0x4b')](_0x2cd091['model'],qs[_0xb213('0x4d')](_0x4c092d[_0xb213('0x48')][_0xb213('0x4d')]));_0x1cd1f6[_0xb213('0x4c')]=_0x1cd1f6[_0xb213('0x4c')][_0xb213('0x4e')]?_0x1cd1f6[_0xb213('0x4c')]:_0x2cd091['model'];if(!_0x4c092d[_0xb213('0x48')][_0xb213('0x4f')](_0xb213('0x50'))){_0x1cd1f6[_0xb213('0x31')]=qs[_0xb213('0x31')](_0x4c092d[_0xb213('0x48')][_0xb213('0x31')]);_0x1cd1f6[_0xb213('0x2f')]=qs[_0xb213('0x2f')](_0x4c092d['query']['offset']);}_0x1cd1f6['order']=qs['sort'](_0x4c092d[_0xb213('0x48')]['sort']);_0x1cd1f6[_0xb213('0x51')]=qs[_0xb213('0x4a')](_['pick'](_0x4c092d[_0xb213('0x48')],_0x2cd091[_0xb213('0x4a')]),_0x15d73d);if(_0x4c092d[_0xb213('0x48')]['filter']){_0x1cd1f6[_0xb213('0x51')]=_['merge'](_0x1cd1f6[_0xb213('0x51')],{'$or':_[_0xb213('0x42')](_0x15d73d,function(_0x4e28b0){if(_0x4e28b0[_0xb213('0x45')]!==_0xb213('0x52')){var _0x540e03={};_0x540e03[_0x4e28b0[_0xb213('0x3d')]]={'$like':'%'+_0x4c092d['query']['filter']+'%'};return _0x540e03;}})});}_0x1cd1f6=_[_0xb213('0x53')]({},_0x1cd1f6,_0x4c092d[_0xb213('0x54')]);var _0x3549a8={'where':_0x1cd1f6['where']};return db[_0xb213('0x43')]['count'](_0x3549a8)[_0xb213('0x20')](function(_0x488d71){_0x531521['count']=_0x488d71;if(_0x4c092d[_0xb213('0x48')][_0xb213('0x55')]){_0x1cd1f6[_0xb213('0x56')]=[{'all':!![]}];}return db[_0xb213('0x43')]['findAll'](_0x1cd1f6);})[_0xb213('0x20')](function(_0x26488f){_0x531521[_0xb213('0x57')]=_0x26488f;return _0x531521;})[_0xb213('0x20')](respondWithFilteredResult(_0xe9840e,_0x1cd1f6))[_0xb213('0x58')](handleError(_0xe9840e,null));};exports[_0xb213('0x59')]=function(_0x24a1a4,_0x18fa78){var _0x510e16={'raw':![],'where':{'id':_0x24a1a4[_0xb213('0x5a')]['id']},'include':[{'model':db[_0xb213('0x40')],'as':_0xb213('0x41')}]},_0x3761d1={};_0x3761d1[_0xb213('0x47')]=_[_0xb213('0x49')](db[_0xb213('0x43')]['rawAttributes']);_0x3761d1[_0xb213('0x48')]=_[_0xb213('0x49')](_0x24a1a4[_0xb213('0x48')]);_0x3761d1[_0xb213('0x4a')]=_[_0xb213('0x4b')](_0x3761d1[_0xb213('0x47')],_0x3761d1[_0xb213('0x48')]);_0x510e16['attributes']=_[_0xb213('0x4b')](_0x3761d1[_0xb213('0x47')],qs[_0xb213('0x4d')](_0x24a1a4['query'][_0xb213('0x4d')]));_0x510e16['attributes']=_0x510e16[_0xb213('0x4c')]['length']?_0x510e16['attributes']:_0x3761d1[_0xb213('0x47')];if(_0x24a1a4[_0xb213('0x48')]['includeAll']){_0x510e16[_0xb213('0x56')]=[{'all':!![]}];}_0x510e16=_[_0xb213('0x53')]({},_0x510e16,_0x24a1a4[_0xb213('0x54')]);return db['FaxAccount'][_0xb213('0x5b')](_0x510e16)[_0xb213('0x20')](handleEntityNotFound(_0x18fa78,null))['then'](respondWithResult(_0x18fa78,null))[_0xb213('0x58')](handleError(_0x18fa78,null));};exports[_0xb213('0x5c')]=function(_0x5e5654,_0x1eaa59){return db['FaxAccount'][_0xb213('0x5c')](_0x5e5654[_0xb213('0x5d')],{})[_0xb213('0x20')](function(_0x1bd55e){var _0x2469e9=_0x5e5654['user'][_0xb213('0x39')]({'plain':!![]});if(!_0x2469e9)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2469e9[_0xb213('0x5e')]==='user'){var _0x2e3902=_0x1bd55e[_0xb213('0x39')]({'plain':!![]});var _0x380617=_0xb213('0x3a');return db[_0xb213('0x5f')]['find']({'where':{'name':_0x380617,'userProfileId':_0x2469e9['userProfileId']},'raw':!![]})['then'](function(_0x15844c){if(_0x15844c&&_0x15844c[_0xb213('0x60')]===0x0){return db['UserProfileResource']['create']({'name':_0x2e3902['name'],'resourceId':_0x2e3902['id'],'type':_0x15844c[_0xb213('0x3d')],'sectionId':_0x15844c['id']},{})[_0xb213('0x20')](function(){return _0x1bd55e;});}else{return _0x1bd55e;}})['catch'](function(_0x58463c){logger[_0xb213('0x27')](_0xb213('0x61'),_0x58463c);throw _0x58463c;});}return _0x1bd55e;})[_0xb213('0x20')](respondWithResult(_0x1eaa59,0xc9))[_0xb213('0x58')](handleError(_0x1eaa59,null));};exports['update']=function(_0x301873,_0x4b793a){if(_0x301873[_0xb213('0x5d')]['id']){delete _0x301873[_0xb213('0x5d')]['id'];}return db['FaxAccount'][_0xb213('0x5b')]({'where':{'id':_0x301873[_0xb213('0x5a')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]})[_0xb213('0x20')](handleEntityNotFound(_0x4b793a,null))[_0xb213('0x20')](saveUpdates(_0x301873[_0xb213('0x5d')],null))[_0xb213('0x20')](respondWithResult(_0x4b793a,null))[_0xb213('0x58')](handleError(_0x4b793a,null));};exports[_0xb213('0x38')]=function(_0x5303a5,_0x86fec6){return db[_0xb213('0x43')][_0xb213('0x5b')]({'where':{'id':_0x5303a5[_0xb213('0x5a')]['id']}})['then'](handleEntityNotFound(_0x86fec6,null))[_0xb213('0x20')](removeEntity(_0x86fec6,null))[_0xb213('0x58')](handleError(_0x86fec6,null));};exports[_0xb213('0x62')]=function(_0x521c30,_0x4fbe3f){return db[_0xb213('0x43')][_0xb213('0x62')]()[_0xb213('0x20')](respondWithResult(_0x4fbe3f,null))[_0xb213('0x58')](handleError(_0x4fbe3f,null));};exports[_0xb213('0x63')]=function(_0x4967c4,_0x449522,_0x543dfd){if(_0x4967c4[_0xb213('0x5d')]['id']){delete _0x4967c4[_0xb213('0x5d')]['id'];}return db['FaxAccount'][_0xb213('0x5b')]({'where':{'id':_0x4967c4['params']['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x449522,null))[_0xb213('0x20')](function(_0x284d88){if(_0x284d88){_0x4967c4[_0xb213('0x5d')][_0xb213('0x64')]=_0x284d88['id'];return db[_0xb213('0x65')]['create'](_0x4967c4[_0xb213('0x5d')]);}})[_0xb213('0x20')](respondWithResult(_0x449522,null))['catch'](handleError(_0x449522,null));};exports['getDispositions']=function(_0x4bbdec,_0x19e149,_0x472276){var _0x15b6b7={'raw':![],'where':{}};var _0x9d464d={};var _0x1b5511={'count':0x0,'rows':[]};return db[_0xb213('0x43')][_0xb213('0x66')]({'where':{'id':_0x4bbdec[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x19e149,null))[_0xb213('0x20')](function(_0x53fafa){if(_0x53fafa){_0x9d464d[_0xb213('0x47')]=_['keys'](db[_0xb213('0x65')][_0xb213('0x67')]);_0x9d464d[_0xb213('0x48')]=_['keys'](_0x4bbdec[_0xb213('0x48')]);_0x9d464d[_0xb213('0x4a')]=_[_0xb213('0x4b')](_0x9d464d[_0xb213('0x47')],_0x9d464d[_0xb213('0x48')]);_0x15b6b7[_0xb213('0x4c')]=_['intersection'](_0x9d464d[_0xb213('0x47')],qs[_0xb213('0x4d')](_0x4bbdec[_0xb213('0x48')][_0xb213('0x4d')]));_0x15b6b7[_0xb213('0x4c')]=_0x15b6b7['attributes'][_0xb213('0x4e')]?_0x15b6b7[_0xb213('0x4c')]:_0x9d464d[_0xb213('0x47')];if(!_0x4bbdec[_0xb213('0x48')][_0xb213('0x4f')](_0xb213('0x50'))){_0x15b6b7[_0xb213('0x31')]=qs[_0xb213('0x31')](_0x4bbdec[_0xb213('0x48')][_0xb213('0x31')]);_0x15b6b7['offset']=qs['offset'](_0x4bbdec[_0xb213('0x48')][_0xb213('0x2f')]);}_0x15b6b7[_0xb213('0x68')]=qs[_0xb213('0x69')](_0x4bbdec[_0xb213('0x48')]['sort']);_0x15b6b7['where']=qs[_0xb213('0x4a')](_[_0xb213('0x6a')](_0x4bbdec[_0xb213('0x48')],_0x9d464d[_0xb213('0x4a')]));_0x15b6b7[_0xb213('0x51')][_0xb213('0x64')]=_0x53fafa['id'];if(_0x4bbdec[_0xb213('0x48')][_0xb213('0x6b')]){_0x15b6b7[_0xb213('0x51')]=_[_0xb213('0x53')](_0x15b6b7[_0xb213('0x51')],{'$or':_[_0xb213('0x42')](_0x15b6b7[_0xb213('0x4c')],function(_0x36c1bd){var _0x3008ba={};_0x3008ba[_0x36c1bd]={'$like':'%'+_0x4bbdec['query'][_0xb213('0x6b')]+'%'};return _0x3008ba;})});}_0x15b6b7=_[_0xb213('0x53')]({},_0x15b6b7,_0x4bbdec[_0xb213('0x54')]);return db[_0xb213('0x65')]['count']({'where':_0x15b6b7[_0xb213('0x51')]})[_0xb213('0x20')](function(_0x15b4e6){_0x1b5511[_0xb213('0x32')]=_0x15b4e6;if(_0x4bbdec[_0xb213('0x48')][_0xb213('0x55')]){_0x15b6b7[_0xb213('0x56')]=[{'all':!![]}];}return db[_0xb213('0x65')][_0xb213('0x6c')](_0x15b6b7);})['then'](function(_0x94b002){_0x1b5511[_0xb213('0x57')]=_0x94b002;return _0x1b5511;});}})[_0xb213('0x20')](respondWithFilteredResult(_0x19e149,_0x15b6b7))[_0xb213('0x58')](handleError(_0x19e149,null));};exports[_0xb213('0x6d')]=function(_0x248c4c,_0x28b5eb,_0x234c2a){return db[_0xb213('0x43')]['find']({'where':{'id':_0x248c4c[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x28b5eb,null))[_0xb213('0x20')](function(_0xe75b50){if(_0xe75b50){return _0xe75b50[_0xb213('0x6d')](_0x248c4c[_0xb213('0x48')][_0xb213('0x6e')]);}})['then'](respondWithStatusCode(_0x28b5eb,null))[_0xb213('0x58')](handleError(_0x28b5eb,null));};exports[_0xb213('0x6f')]=function(_0x22f562,_0xe2abad,_0xef5652){if(_0x22f562[_0xb213('0x5d')]['id']){delete _0x22f562['body']['id'];}return db[_0xb213('0x43')][_0xb213('0x5b')]({'where':{'id':_0x22f562[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0xe2abad,null))[_0xb213('0x20')](function(_0xd9aa5e){if(_0xd9aa5e){_0x22f562['body'][_0xb213('0x64')]=_0xd9aa5e['id'];return db[_0xb213('0x70')][_0xb213('0x5c')](_0x22f562[_0xb213('0x5d')]);}})[_0xb213('0x20')](respondWithResult(_0xe2abad,null))[_0xb213('0x58')](handleError(_0xe2abad,null));};exports[_0xb213('0x71')]=function(_0xe2823e,_0x467c34,_0x412ae2){var _0x18fc18={'raw':![],'where':{}};var _0x1c494e={};var _0x97372a={'count':0x0,'rows':[]};return db[_0xb213('0x43')]['findOne']({'where':{'id':_0xe2823e[_0xb213('0x5a')]['id']}})['then'](handleEntityNotFound(_0x467c34,null))[_0xb213('0x20')](function(_0x56e6fe){if(_0x56e6fe){_0x1c494e[_0xb213('0x47')]=_[_0xb213('0x49')](db[_0xb213('0x70')][_0xb213('0x67')]);_0x1c494e[_0xb213('0x48')]=_['keys'](_0xe2823e[_0xb213('0x48')]);_0x1c494e['filters']=_[_0xb213('0x4b')](_0x1c494e['model'],_0x1c494e[_0xb213('0x48')]);_0x18fc18[_0xb213('0x4c')]=_[_0xb213('0x4b')](_0x1c494e[_0xb213('0x47')],qs[_0xb213('0x4d')](_0xe2823e[_0xb213('0x48')][_0xb213('0x4d')]));_0x18fc18[_0xb213('0x4c')]=_0x18fc18[_0xb213('0x4c')]['length']?_0x18fc18[_0xb213('0x4c')]:_0x1c494e['model'];if(!_0xe2823e[_0xb213('0x48')][_0xb213('0x4f')]('nolimit')){_0x18fc18[_0xb213('0x31')]=qs['limit'](_0xe2823e[_0xb213('0x48')][_0xb213('0x31')]);_0x18fc18[_0xb213('0x2f')]=qs['offset'](_0xe2823e[_0xb213('0x48')]['offset']);}_0x18fc18[_0xb213('0x68')]=qs[_0xb213('0x69')](_0xe2823e['query']['sort']);_0x18fc18[_0xb213('0x51')]=qs[_0xb213('0x4a')](_['pick'](_0xe2823e[_0xb213('0x48')],_0x1c494e['filters']));_0x18fc18[_0xb213('0x51')][_0xb213('0x64')]=_0x56e6fe['id'];if(_0xe2823e['query'][_0xb213('0x6b')]){_0x18fc18[_0xb213('0x51')]=_[_0xb213('0x53')](_0x18fc18[_0xb213('0x51')],{'$or':_[_0xb213('0x42')](_0x18fc18[_0xb213('0x4c')],function(_0xc9bee7){var _0x2318ec={};_0x2318ec[_0xc9bee7]={'$like':'%'+_0xe2823e[_0xb213('0x48')]['filter']+'%'};return _0x2318ec;})});}_0x18fc18=_[_0xb213('0x53')]({},_0x18fc18,_0xe2823e['options']);return db[_0xb213('0x70')]['count']({'where':_0x18fc18[_0xb213('0x51')]})[_0xb213('0x20')](function(_0x537e3a){_0x97372a['count']=_0x537e3a;if(_0xe2823e['query'][_0xb213('0x55')]){_0x18fc18[_0xb213('0x56')]=[{'all':!![]}];}return db[_0xb213('0x70')]['findAll'](_0x18fc18);})['then'](function(_0x5d9305){_0x97372a[_0xb213('0x57')]=_0x5d9305;return _0x97372a;});}})[_0xb213('0x20')](respondWithFilteredResult(_0x467c34,_0x18fc18))['catch'](handleError(_0x467c34,null));};exports['removeAnswers']=function(_0x2e4648,_0x183d3a,_0x484887){return db[_0xb213('0x43')][_0xb213('0x5b')]({'where':{'id':_0x2e4648[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x183d3a,null))['then'](function(_0x1d709d){if(_0x1d709d){return _0x1d709d[_0xb213('0x72')](_0x2e4648[_0xb213('0x48')]['ids']);}})['then'](respondWithStatusCode(_0x183d3a,null))[_0xb213('0x58')](handleError(_0x183d3a,null));};exports[_0xb213('0x73')]=function(_0x339797,_0x2f3a27,_0x28d0a8){return db[_0xb213('0x74')][_0xb213('0x5b')]({'where':{'id':_0x339797[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x2f3a27,null))[_0xb213('0x20')](function(_0x4d44aa){if(_0x4d44aa){return _0x4d44aa['addInteraction'](_0x339797[_0xb213('0x5d')][_0xb213('0x6e')],_['omit'](_0x339797[_0xb213('0x5d')],[_0xb213('0x6e'),'id'])||{});}})[_0xb213('0x20')](respondWithResult(_0x2f3a27,null))[_0xb213('0x58')](handleError(_0x2f3a27,null));};exports[_0xb213('0x75')]=function(_0x3625c6,_0x36dfa1,_0x3acaed){var _0x7de674={'raw':![],'where':{}};var _0x1c5cfb={};var _0x57df09={'count':0x0,'rows':[]};return db[_0xb213('0x43')][_0xb213('0x66')]({'where':{'id':_0x3625c6[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x36dfa1,null))[_0xb213('0x20')](function(_0x1e55d0){if(_0x1e55d0){_0x1c5cfb[_0xb213('0x47')]=_['keys'](db['FaxInteraction'][_0xb213('0x67')]);_0x1c5cfb['query']=_['keys'](_0x3625c6[_0xb213('0x48')]);_0x1c5cfb[_0xb213('0x4a')]=_[_0xb213('0x4b')](_0x1c5cfb[_0xb213('0x47')],_0x1c5cfb['query']);_0x7de674['attributes']=_[_0xb213('0x4b')](_0x1c5cfb[_0xb213('0x47')],qs['fields'](_0x3625c6[_0xb213('0x48')][_0xb213('0x4d')]));_0x7de674[_0xb213('0x4c')]=_0x7de674['attributes'][_0xb213('0x4e')]?_0x7de674[_0xb213('0x4c')]:_0x1c5cfb['model'];if(!_0x3625c6[_0xb213('0x48')][_0xb213('0x4f')](_0xb213('0x50'))){_0x7de674[_0xb213('0x31')]=qs[_0xb213('0x31')](_0x3625c6[_0xb213('0x48')][_0xb213('0x31')]);_0x7de674['offset']=qs[_0xb213('0x2f')](_0x3625c6[_0xb213('0x48')][_0xb213('0x2f')]);}_0x7de674['order']=qs['sort'](_0x3625c6[_0xb213('0x48')]['sort']);_0x7de674['where']=qs[_0xb213('0x4a')](_[_0xb213('0x6a')](_0x3625c6['query'],_0x1c5cfb[_0xb213('0x4a')]));_0x7de674['where'][_0xb213('0x64')]=_0x1e55d0['id'];if(_0x3625c6[_0xb213('0x48')][_0xb213('0x6b')]){_0x7de674[_0xb213('0x51')]=_['merge'](_0x7de674[_0xb213('0x51')],{'$or':_[_0xb213('0x42')](_0x7de674['attributes'],function(_0x33d140){var _0x25b4f4={};_0x25b4f4[_0x33d140]={'$like':'%'+_0x3625c6[_0xb213('0x48')][_0xb213('0x6b')]+'%'};return _0x25b4f4;})});}_0x7de674=_[_0xb213('0x53')]({},_0x7de674,_0x3625c6[_0xb213('0x54')]);return db[_0xb213('0x74')][_0xb213('0x32')]({'where':_0x7de674['where']})[_0xb213('0x20')](function(_0x4f38f1){_0x57df09[_0xb213('0x32')]=_0x4f38f1;if(_0x3625c6[_0xb213('0x48')][_0xb213('0x55')]){_0x7de674[_0xb213('0x56')]=[{'model':db[_0xb213('0x76')],'as':_0xb213('0x77'),'required':![]},{'model':db['User'],'as':_0xb213('0x78'),'attributes':[_0xb213('0x3d'),'fullname',_0xb213('0x79')],'required':![]},{'model':db[_0xb213('0x7a')],'as':_0xb213('0x7b'),'attributes':['id',_0xb213('0x3d'),_0xb213('0x7c')],'where':_0x3625c6['query'][_0xb213('0x7d')]?{'id':_0x3625c6['query'][_0xb213('0x7d')]}:undefined,'required':_0x3625c6[_0xb213('0x48')][_0xb213('0x7d')]?!![]:![]}];}return db[_0xb213('0x74')]['findAll'](_0x7de674);})['then'](function(_0x228518){_0x57df09['rows']=_0x228518;return _0x57df09;});}})[_0xb213('0x20')](respondWithFilteredResult(_0x36dfa1,_0x7de674))[_0xb213('0x58')](handleError(_0x36dfa1,null));};exports[_0xb213('0x7e')]=function(_0x1fe76f,_0x53d455){var _0x1acd50=_0x1fe76f[_0xb213('0x5a')]['id'];var _0x4e3cfb=_0x1fe76f[_0xb213('0x5d')];var _0x2a436f=0xc8;var _0x57e596=null;return db[_0xb213('0x7f')][_0xb213('0x80')]({'isolationLevel':db[_0xb213('0x7f')][_0xb213('0x81')][_0xb213('0x82')][_0xb213('0x83')]},function(_0x1d0e50){return db['FaxAccount']['findOne']({'where':{'id':_0x1acd50},'transaction':_0x1d0e50})['then'](function(_0x3e4879){if(_0x3e4879){return db[_0xb213('0x84')][_0xb213('0x38')]({'where':{'FaxAccountId':_0x1acd50},'transaction':_0x1d0e50})[_0xb213('0x20')](function(){var _0x12802e=_[_0xb213('0x42')](_0x4e3cfb,function(_0x464c8e){_0x464c8e[_0xb213('0x64')]=_0x1acd50;return _0x464c8e;});return db[_0xb213('0x84')][_0xb213('0x85')](_0x12802e,{'transaction':_0x1d0e50});});}else{_0x2a436f=0x194;_0x57e596=[];}});})['then'](function(){if(_0x2a436f!==0x194){return db[_0xb213('0x84')][_0xb213('0x86')]({'where':{'FaxAccountId':_0x1acd50},'order':'priority'})['then'](function(_0x41ee19){_0x57e596=_0x41ee19;});}})[_0xb213('0x58')](function(_0x45c447){_0x2a436f=0x1f4;logger[_0xb213('0x27')](_0x45c447[_0xb213('0x3c')]);if(_0x45c447[_0xb213('0x3d')]){delete _0x45c447[_0xb213('0x3d')];}_0x57e596=_0x45c447;})[_0xb213('0x87')](function(){if(_0x57e596===null){_0x53d455[_0xb213('0x2b')](_0x2a436f);}else{if(_0x2a436f===0x1f4){_0x53d455[_0xb213('0x2c')](_0x2a436f)[_0xb213('0x3e')](_0x57e596);}else{_0x53d455['status'](_0x2a436f)[_0xb213('0x2e')](_0x57e596);}}});};exports[_0xb213('0x88')]=function(_0x35d6d4,_0x5494c1,_0x5770be){var _0xc03a05={};var _0xfe4106={};var _0x161d9d;var _0x8652de;return db[_0xb213('0x43')]['findOne']({'where':{'id':_0x35d6d4[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x5494c1,null))[_0xb213('0x20')](function(_0x2acc6b){if(_0x2acc6b){_0x161d9d=_0x2acc6b;_0xfe4106[_0xb213('0x47')]=_['keys'](db[_0xb213('0x84')][_0xb213('0x67')]);_0xfe4106['query']=_[_0xb213('0x49')](_0x35d6d4[_0xb213('0x48')]);_0xfe4106[_0xb213('0x4a')]=_[_0xb213('0x4b')](_0xfe4106[_0xb213('0x47')],_0xfe4106[_0xb213('0x48')]);_0xc03a05['attributes']=_[_0xb213('0x4b')](_0xfe4106[_0xb213('0x47')],qs[_0xb213('0x4d')](_0x35d6d4[_0xb213('0x48')][_0xb213('0x4d')]));_0xc03a05[_0xb213('0x4c')]=_0xc03a05['attributes'][_0xb213('0x4e')]?_0xc03a05['attributes']:_0xfe4106[_0xb213('0x47')];_0xc03a05['order']=qs[_0xb213('0x69')](_0x35d6d4[_0xb213('0x48')][_0xb213('0x69')]);_0xc03a05[_0xb213('0x51')]=qs[_0xb213('0x4a')](_[_0xb213('0x6a')](_0x35d6d4[_0xb213('0x48')],_0xfe4106[_0xb213('0x4a')]));if(_0x35d6d4['query'][_0xb213('0x6b')]){_0xc03a05['where']=_[_0xb213('0x53')](_0xc03a05[_0xb213('0x51')],{'$or':_['map'](_0xc03a05['attributes'],function(_0x50b54c){var _0x555043={};_0x555043[_0x50b54c]={'$like':'%'+_0x35d6d4[_0xb213('0x48')][_0xb213('0x6b')]+'%'};return _0x555043;})});}_0xc03a05=_[_0xb213('0x53')]({},_0xc03a05,_0x35d6d4['options']);return _0x161d9d[_0xb213('0x88')](_0xc03a05);}})[_0xb213('0x20')](function(_0x280a9a){if(_0x280a9a){_0x8652de=_0x280a9a['length'];if(!_0x35d6d4['query']['hasOwnProperty'](_0xb213('0x50'))){_0xc03a05[_0xb213('0x31')]=qs[_0xb213('0x31')](_0x35d6d4['query'][_0xb213('0x31')]);_0xc03a05[_0xb213('0x2f')]=qs[_0xb213('0x2f')](_0x35d6d4['query'][_0xb213('0x2f')]);}return _0x161d9d[_0xb213('0x88')](_0xc03a05);}})[_0xb213('0x20')](function(_0x105d25){if(_0x105d25){return _0x105d25?{'count':_0x8652de,'rows':_0x105d25}:null;}})['then'](respondWithResult(_0x5494c1,null))['catch'](handleError(_0x5494c1,null));};function Extension(_0x3953fd,_0x5cd77b,_0x3a2f45,_0x479367){this[_0xb213('0x89')]='from-voip-provider';this[_0xb213('0x8a')]=_0x3953fd[_0xb213('0x8b')];this[_0xb213('0x8c')]=_0x479367;this['type']=_0xb213('0x8d');this[_0xb213('0x8e')]=_0xb213('0x8f');this[_0xb213('0x64')]=_0x3953fd['id'];this[_0xb213('0x90')]=_0x5cd77b;this[_0xb213('0x91')]=_0x3a2f45;}function createExtensionsReciveFax(_0x6c60de){var _0x127ec5=0x1;var _0x36df5e=[];_0x36df5e[_0xb213('0x92')](new Extension(_0x6c60de,_0x127ec5,'','Answer'));_0x127ec5+=0x1;_0x36df5e[_0xb213('0x92')](new Extension(_0x6c60de,_0x127ec5,_0xb213('0x93'),_0xb213('0x94')));_0x127ec5+=0x1;for(var _0x3325e5 in _0x6c60de){if(_0x6c60de['hasOwnProperty'](_0x3325e5)&&(_0x3325e5==='ecm'||_0x3325e5===_0xb213('0x8b')||_0x3325e5===_0xb213('0x95')||_0x3325e5==='faxdetect'||_0x3325e5===_0xb213('0x96')||_0x3325e5==='maxrate'||_0x3325e5===_0xb213('0x97')||_0x3325e5==='modem'||_0x3325e5===_0xb213('0x98'))){_0x36df5e[_0xb213('0x92')](new Extension(_0x6c60de,_0x127ec5,_0xb213('0x99')+_0x3325e5+')='+_0x6c60de[_0x3325e5],_0xb213('0x94')));_0x127ec5+=0x1;}}_0x36df5e[_0xb213('0x92')](new Extension(_0x6c60de,_0x127ec5,'6',_0xb213('0x9a')));_0x127ec5+=0x1;_0x36df5e['push'](new Extension(_0x6c60de,_0x127ec5,_0xb213('0x9b'),_0xb213('0x9c')));_0x127ec5=0x0;return _0x36df5e;}exports[_0xb213('0x9d')]=function(_0x576987,_0x5af659,_0x5095aa){var _0x3bb0e7;return db[_0xb213('0x7f')]['transaction'](function(_0x60f614){return db['FaxAccount'][_0xb213('0x5c')](_0x576987[_0xb213('0x5d')],{'transaction':_0x60f614})[_0xb213('0x20')](function(_0x36e9d4){_0x3bb0e7=_0x36e9d4['get']({'plain':!![]});return db[_0xb213('0x9e')][_0xb213('0x85')](createExtensionsReciveFax(_0x3bb0e7),{'transaction':_0x60f614});});})[_0xb213('0x20')](function(){return _0x3bb0e7;})[_0xb213('0x20')](respondWithResult(_0x5af659,null))['catch'](handleError(_0x5af659,null));};exports[_0xb213('0x9f')]=function(_0x25e455,_0x15b7d8,_0x164960){var _0x5df8bc;return db[_0xb213('0x7f')]['transaction'](function(_0x457b6e){return db['FaxAccount'][_0xb213('0x37')](_0x25e455[_0xb213('0x5d')],{'where':{'id':_0x25e455[_0xb213('0x5d')]['id']},'transaction':_0x457b6e})[_0xb213('0x20')](function(_0xcbd159){return db['VoiceExtension'][_0xb213('0x38')]({'where':{'FaxAccountId':_0x25e455['body']['id']},'transaction':_0x457b6e})[_0xb213('0x20')](function(_0x30dd11){return db['VoiceExtension'][_0xb213('0x85')](createExtensionsReciveFax(_['omit'](_0x25e455[_0xb213('0x5d')],['tech',_0xb213('0x46'),_0xb213('0xa0'),_0xb213('0xa1'),'TrunkId',_0xb213('0xa2')])),{'transaction':_0x457b6e});});});})[_0xb213('0x20')](function(){return db['FaxAccount'][_0xb213('0xa3')](_0x25e455[_0xb213('0x5d')]['id']);})[_0xb213('0x20')](respondWithResult(_0x15b7d8,null))[_0xb213('0x58')](handleError(_0x15b7d8,null));};exports[_0xb213('0xa4')]=function(_0x28a285,_0x537260,_0x2935d6){var _0x10977e={'raw':!![],'where':{}};var _0x3d54a4={};var _0xc98e3c={'count':0x0,'rows':[]};return db['FaxAccount'][_0xb213('0x66')]({'where':{'id':_0x28a285[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x537260,null))[_0xb213('0x20')](function(_0x4b1664){if(_0x4b1664){_0x3d54a4[_0xb213('0x47')]=_[_0xb213('0x49')](db[_0xb213('0xa5')][_0xb213('0x67')]);_0x3d54a4[_0xb213('0x48')]=_[_0xb213('0x49')](_0x28a285[_0xb213('0x48')]);_0x3d54a4[_0xb213('0x4a')]=_[_0xb213('0x4b')](_0x3d54a4[_0xb213('0x47')],_0x3d54a4[_0xb213('0x48')]);_0x10977e[_0xb213('0x4c')]=_[_0xb213('0x4b')](_0x3d54a4['model'],qs[_0xb213('0x4d')](_0x28a285[_0xb213('0x48')]['fields']));_0x10977e[_0xb213('0x4c')]=_0x10977e[_0xb213('0x4c')]['length']?_0x10977e[_0xb213('0x4c')]:_0x3d54a4[_0xb213('0x47')];if(!_0x28a285[_0xb213('0x48')][_0xb213('0x4f')](_0xb213('0x50'))){_0x10977e['limit']=qs[_0xb213('0x31')](_0x28a285['query'][_0xb213('0x31')]);_0x10977e[_0xb213('0x2f')]=qs[_0xb213('0x2f')](_0x28a285[_0xb213('0x48')][_0xb213('0x2f')]);}_0x10977e[_0xb213('0x68')]=qs[_0xb213('0x69')](_0x28a285[_0xb213('0x48')][_0xb213('0x69')]);_0x10977e[_0xb213('0x51')]=qs[_0xb213('0x4a')](_['pick'](_0x28a285[_0xb213('0x48')],_0x3d54a4['filters']));_0x10977e['where']['FaxAccountId']=_0x4b1664['id'];if(_0x28a285['query'][_0xb213('0x6b')]){_0x10977e[_0xb213('0x51')]=_[_0xb213('0x53')](_0x10977e[_0xb213('0x51')],{'$or':_[_0xb213('0x42')](_0x10977e[_0xb213('0x4c')],function(_0x169aeb){var _0x1421a0={};_0x1421a0[_0x169aeb]={'$like':'%'+_0x28a285[_0xb213('0x48')][_0xb213('0x6b')]+'%'};return _0x1421a0;})});}if(_0x28a285[_0xb213('0x48')][_0xb213('0xa6')]){var _0x4e31f1=_0x28a285[_0xb213('0x48')]['$gte'][_0xb213('0xa7')](',');var _0x5e11b8={};_0x5e11b8[_0x4e31f1[0x0]]={'$gte':moment(_0x4e31f1[0x1])['format'](_0xb213('0xa8'))};_0x10977e[_0xb213('0x51')]=_['merge'](_0x10977e[_0xb213('0x51')],_0x5e11b8);}_0x10977e=_[_0xb213('0x53')]({},_0x10977e,_0x28a285[_0xb213('0x54')]);return db[_0xb213('0xa5')]['count']({'where':_0x10977e[_0xb213('0x51')]})[_0xb213('0x20')](function(_0x3ec9f2){_0xc98e3c['count']=_0x3ec9f2;if(_0x28a285[_0xb213('0x48')][_0xb213('0x55')]){_0x10977e[_0xb213('0x56')]=[{'all':!![]}];}return db[_0xb213('0xa5')][_0xb213('0x6c')](_0x10977e);})[_0xb213('0x20')](function(_0xf336b2){_0xc98e3c[_0xb213('0x57')]=_0xf336b2;return _0xc98e3c;});}})[_0xb213('0x20')](respondWithFilteredResult(_0x537260,_0x10977e))[_0xb213('0x58')](handleError(_0x537260,null));};exports['send']=function(_0xf805a1,_0x4cc57f,_0x5a0be6){var _0xd95068,_0xa2a976={},_0x521f06;if(_0xf805a1['body']['to']){_0x521f06=_0xf805a1[_0xb213('0x5d')]['to'][0x0];}return db[_0xb213('0x43')][_0xb213('0x5b')]({'where':{'id':_0xf805a1[_0xb213('0x5a')]['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db['CmContact'],'as':_0xb213('0xa9'),'where':{'fax':_0x521f06},'limit':0x1,'order':[[_0xb213('0xa1'),_0xb213('0xaa')]]}]}]})[_0xb213('0x20')](handleEntityNotFound(_0x4cc57f,null))[_0xb213('0x20')](function(_0x2c1405){_0xd95068=_0x2c1405;if(_0xf805a1[_0xb213('0x5d')][_0xb213('0xab')]&&_0xf805a1['body']['attachments'][_0xb213('0x4e')]){for(var _0x1178a4=0x0;_0x1178a4<_0xf805a1[_0xb213('0x5d')]['attachments'][_0xb213('0x4e')];_0x1178a4+=0x1){_0xf805a1['body'][_0xb213('0xab')][_0x1178a4]={'filename':_0xf805a1[_0xb213('0x5d')][_0xb213('0xab')][_0x1178a4]['name'],'id':_0xf805a1['body']['attachments'][_0x1178a4]['id'],'path':path[_0xb213('0xac')](config[_0xb213('0xad')],_0xb213('0xae'),_0xf805a1[_0xb213('0x5d')]['attachments'][_0x1178a4][_0xb213('0xaf')])};}}return respondWithRpcPromise(_0xb213('0xb0'),_0xb213('0xb0'),{'FaxAccountId':_[_0xb213('0xb1')](_0xf805a1[_0xb213('0x5a')]['id'])?undefined:_0xf805a1[_0xb213('0x5a')]['id'],'path':_[_0xb213('0xb1')](_0xf805a1[_0xb213('0x5d')]['attachments'][0x0][_0xb213('0x7')])?undefined:_0xf805a1['body'][_0xb213('0xab')][0x0][_0xb213('0x7')],'fax':_[_0xb213('0xb1')](_0xf805a1[_0xb213('0x5d')]['to'][0x0])?undefined:_0xf805a1[_0xb213('0x5d')]['to'][0x0]},client9002);})[_0xb213('0x20')](function(){if(_0xd95068){if(_['isNil'](_0xf805a1[_0xb213('0x5d')][_0xb213('0xb2')])){_0xf805a1[_0xb213('0x5d')][_0xb213('0xb2')]=util[_0xb213('0xb3')]('\x22%s\x22\x20<%s>',_0xd95068[_0xb213('0x3d')],_0xd95068['fax']);}if(_0xd95068[_0xb213('0xb4')]){if(_0xd95068['List'][_0xb213('0xa9')][_0xb213('0x4e')]){return _0xd95068[_0xb213('0xb4')][_0xb213('0xa9')][0x0];}else{return db[_0xb213('0x76')]['create'](_[_0xb213('0x1a')](_0xf805a1[_0xb213('0x5d')],{'firstName':_0xf805a1['body']['to'][0x0],'phone':_0xf805a1[_0xb213('0x5d')]['to'][0x0],'fax':_0xf805a1['body']['to'][0x0],'ListId':_0xd95068[_0xb213('0xa2')]}));}}else{throw new Error(_0xb213('0xb5'));}}else{throw new Error('Send\x20Fax\x20failed');}})['then'](function(_0x356d40){if(_0x356d40){return db[_0xb213('0x74')]['find']({'where':{'ContactId':_0x356d40['id'],'closed':![],'FaxAccountId':_0xd95068['id']}})['then'](function(_0x3c6108){if(_0x3c6108){return[_0x3c6108,![]];}return db[_0xb213('0x74')]['create']({'UserId':_0xf805a1[_0xb213('0xb6')]['id'],'ContactId':_0x356d40['id'],'FaxAccountId':_0xd95068['id'],'fax':_0xf805a1[_0xb213('0x5d')]['to'][0x0],'firstMsgDirection':_0xb213('0xb7'),'Messages':[_[_0xb213('0x53')](_0xf805a1[_0xb213('0x5d')],{'read':![],'body':_0xf805a1['body'][_0xb213('0xab')][0x0]['filename'],'FaxAccountId':_0xd95068['id'],'UserId':_0xf805a1[_0xb213('0xb6')]['id'],'ContactId':_0x356d40['id'],'AttachmentId':_0xf805a1[_0xb213('0x5d')][_0xb213('0xab')][0x0]['id']})]},{'include':[{'model':db[_0xb213('0xa5')],'as':_0xb213('0xb8')}]})[_0xb213('0x20')](function(_0x36e744){return[_0x36e744,!![]];});});}else{throw new Error(_0xb213('0xb9'));}})[_0xb213('0xba')](function(_0x257efe,_0x3f2fc7){if(_0x3f2fc7){return _0x257efe;}return db['FaxMessage'][_0xb213('0x5c')]({'direction':_0xb213('0xb7'),'read':![],'body':_0xf805a1[_0xb213('0x5d')][_0xb213('0xab')][0x0][_0xb213('0xbb')],'FaxAccountId':_0xd95068['id'],'FaxInteractionId':_0x257efe['id'],'UserId':_0xf805a1[_0xb213('0xb6')]['id'],'ContactId':_0x257efe['ContactId'],'AttachmentId':_0xf805a1[_0xb213('0x5d')][_0xb213('0xab')][0x0]['id']})[_0xb213('0x20')](function(_0x5386d5){_0x257efe[_0xb213('0xbc')][_0xb213('0xb8')]=[];_0x257efe['dataValues'][_0xb213('0xb8')]['push'](_0x5386d5[_0xb213('0xbc')]);return _0x257efe;});})[_0xb213('0x20')](function(_0xa0fed6){respondWithRpcPromise(_0xb213('0xbd'),_0xb213('0xbd'),{'FaxAccountId':_[_0xb213('0xb1')](_0xf805a1[_0xb213('0x5a')]['id'])?undefined:_0xf805a1[_0xb213('0x5a')]['id'],'path':_[_0xb213('0xb1')](_0xf805a1['body'][_0xb213('0xab')][0x0][_0xb213('0x7')])?undefined:_0xf805a1['body'][_0xb213('0xab')][0x0][_0xb213('0x7')],'fax':_[_0xb213('0xb1')](_0xf805a1['body']['to'][0x0])?undefined:_0xf805a1[_0xb213('0x5d')]['to'][0x0],'AttachmentId':_0xf805a1['body']['attachments'][0x0]['id']},client9002)[_0xb213('0x20')](function(_0x3b458a){logger[_0xb213('0x21')]('SendFaxRpc,\x20%s',_0x3b458a);})['catch'](function(_0x3b9841){logger[_0xb213('0x21')](_0xb213('0xbe'),_0x3b9841);});return _0xa0fed6;})[_0xb213('0x20')](respondWithResult(_0x4cc57f,null))['catch'](handleError(_0x4cc57f,null));};exports['addAgents']=function(_0x3e50e3,_0x23c650,_0x35667c){return db['FaxAccount']['find']({'where':{'id':_0x3e50e3[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x23c650,null))['then'](function(_0x4c10ac){if(_0x4c10ac){return _0x4c10ac[_0xb213('0xbf')](_0x3e50e3[_0xb213('0x5d')][_0xb213('0x6e')],_[_0xb213('0xc0')](_0x3e50e3[_0xb213('0x5d')],[_0xb213('0x6e'),'id'])||{})['spread'](function(_0x6b0356){for(var _0x1e4152=0x0;_0x1e4152<_0x3e50e3[_0xb213('0x5d')][_0xb213('0x6e')][_0xb213('0x4e')];_0x1e4152+=0x1){socket[_0xb213('0xc1')]('userFaxAccount:save',{'UserId':Number(_0x3e50e3[_0xb213('0x5d')][_0xb213('0x6e')][_0x1e4152]),'FaxAccountId':Number(_0x3e50e3[_0xb213('0x5a')]['id'])});}return _0x6b0356;});}})[_0xb213('0x20')](respondWithResult(_0x23c650,null))[_0xb213('0x58')](handleError(_0x23c650,null));};exports[_0xb213('0xc2')]=function(_0x19e549,_0x29a42b,_0xd24007){return db[_0xb213('0x43')]['find']({'where':{'id':_0x19e549[_0xb213('0x5a')]['id']}})[_0xb213('0x20')](handleEntityNotFound(_0x29a42b,null))[_0xb213('0x20')](function(_0x167162){if(_0x167162){return _0x167162[_0xb213('0xc2')](_0x19e549[_0xb213('0x48')]['ids'])[_0xb213('0x20')](function(){if(_[_0xb213('0xc3')](_0x19e549[_0xb213('0x48')][_0xb213('0x6e')])){for(var _0x13e87a=0x0;_0x13e87a<_0x19e549[_0xb213('0x48')]['ids'][_0xb213('0x4e')];_0x13e87a+=0x1){socket[_0xb213('0xc1')]('userFaxAccount:remove',{'UserId':Number(_0x19e549[_0xb213('0x48')][_0xb213('0x6e')][_0x13e87a]),'FaxAccountId':Number(_0x19e549['params']['id'])});}}else{socket[_0xb213('0xc1')](_0xb213('0xc4'),{'UserId':Number(_0x19e549[_0xb213('0x48')][_0xb213('0x6e')]),'FaxAccountId':Number(_0x19e549[_0xb213('0x5a')]['id'])});}});}})['then'](respondWithStatusCode(_0x29a42b,null))['catch'](handleError(_0x29a42b,null));};exports[_0xb213('0xc5')]=function(_0x253c72,_0x6b373a,_0xf9ad1d){var _0x3e8b90={};var _0x5d6301={};var _0x1dcd64;var _0x9d53c7;return db[_0xb213('0x43')][_0xb213('0x66')]({'where':{'id':_0x253c72[_0xb213('0x5a')]['id']}})['then'](handleEntityNotFound(_0x6b373a,null))['then'](function(_0x70a067){if(_0x70a067){_0x1dcd64=_0x70a067;_0x5d6301[_0xb213('0x47')]=_['keys'](db[_0xb213('0xc6')]['rawAttributes']);_0x5d6301[_0xb213('0x48')]=_[_0xb213('0x49')](_0x253c72[_0xb213('0x48')]);_0x5d6301[_0xb213('0x4a')]=_[_0xb213('0x4b')](_0x5d6301['model'],_0x5d6301['query']);_0x3e8b90[_0xb213('0x4c')]=_[_0xb213('0x4b')](_0x5d6301[_0xb213('0x47')],qs[_0xb213('0x4d')](_0x253c72['query'][_0xb213('0x4d')]));_0x3e8b90[_0xb213('0x4c')]=_0x3e8b90[_0xb213('0x4c')]['length']?_0x3e8b90['attributes']:_0x5d6301[_0xb213('0x47')];_0x3e8b90[_0xb213('0x68')]=qs[_0xb213('0x69')](_0x253c72['query'][_0xb213('0x69')]);_0x3e8b90[_0xb213('0x51')]=qs['filters'](_[_0xb213('0x6a')](_0x253c72[_0xb213('0x48')],_0x5d6301[_0xb213('0x4a')]));if(_0x253c72[_0xb213('0x48')][_0xb213('0x6b')]){_0x3e8b90[_0xb213('0x51')]=_[_0xb213('0x53')](_0x3e8b90[_0xb213('0x51')],{'$or':_['map'](_0x3e8b90['attributes'],function(_0x3765cd){var _0x20683e={};_0x20683e[_0x3765cd]={'$like':'%'+_0x253c72[_0xb213('0x48')][_0xb213('0x6b')]+'%'};return _0x20683e;})});}_0x3e8b90=_[_0xb213('0x53')]({},_0x3e8b90,_0x253c72[_0xb213('0x54')]);return _0x1dcd64[_0xb213('0xc5')](_0x3e8b90);}})['then'](function(_0x2ec143){if(_0x2ec143){_0x9d53c7=_0x2ec143[_0xb213('0x4e')];if(!_0x253c72[_0xb213('0x48')][_0xb213('0x4f')](_0xb213('0x50'))){_0x3e8b90['limit']=qs['limit'](_0x253c72[_0xb213('0x48')]['limit']);_0x3e8b90[_0xb213('0x2f')]=qs[_0xb213('0x2f')](_0x253c72['query'][_0xb213('0x2f')]);}return _0x1dcd64[_0xb213('0xc5')](_0x3e8b90);}})[_0xb213('0x20')](function(_0x2e13b7){if(_0x2e13b7){return _0x2e13b7?{'count':_0x9d53c7,'rows':_0x2e13b7}:null;}})[_0xb213('0x20')](respondWithResult(_0x6b373a,null))[_0xb213('0x58')](handleError(_0x6b373a,null));};
\ No newline at end of file
+var _0xdc54=['querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','redis','defaults','socket.io-emitter','./faxAccount.socket','client','http','request','then','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','FaxAccount,\x20%s,\x20%s','message','info','result','sendStatus','status','end','undefined','limit','count','offset','set','Content-Range','json','apply','save','update','destroy','get','FaxAccounts','UserProfileResource','stack','name','send','index','Pause','map','rawAttributes','type','model','query','attributes','intersection','fields','length','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','FaxAccount','includeAll','include','findAll','show','params','mandatoryDispositionPause','keys','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','catch','describe','addDisposition','FaxAccountId','getDispositions','findOne','Disposition','hasOwnProperty','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','rows','removeAnswers','addInteraction','FaxInteraction','omit','getInteractions','CmContact','Contact','internal','Tags','color','tag','addApplications','sequelize','transaction','FaxApplication','bulkCreate','priority','getApplications','context','exten','localstationid','app','system','description','Fax\x20Extension','appdata','push','Answer','CDR(type)=inbound-fax','Set','ecm','gateway','headerinfo','minrate','modem','Wait','ReceiveFax','addAccountApplications','VoiceExtension','updateAccountApplications','key','updatedAt','TrunkId','ListId','findById','FaxMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','Contacts','attachments','join','root','server/files/attachments','basename','CheckAfterSend','isNil','path','from','\x22%s\x22\x20<%s>','fax','List\x20not\x20found','filename','Messages','spread','out','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','emit','userFaxAccount:save','removeAgents','isArray','userFaxAccount:remove','getAgents','User','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv'];(function(_0x3223e8,_0x5d1dc5){var _0x5aabcc=function(_0x125d53){while(--_0x125d53){_0x3223e8['push'](_0x3223e8['shift']());}};_0x5aabcc(++_0x5d1dc5);}(_0xdc54,0xb2));var _0x4dc5=function(_0x2e9855,_0xc91f78){_0x2e9855=_0x2e9855-0x0;var _0x2e8dfc=_0xdc54[_0x2e9855];return _0x2e8dfc;};'use strict';var emlformat=require(_0x4dc5('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x4dc5('0x1'));var jsonpatch=require(_0x4dc5('0x2'));var rp=require(_0x4dc5('0x3'));var moment=require(_0x4dc5('0x4'));var BPromise=require(_0x4dc5('0x5'));var Mustache=require(_0x4dc5('0x6'));var util=require(_0x4dc5('0x7'));var path=require('path');var sox=require(_0x4dc5('0x8'));var csv=require('to-csv');var ejs=require(_0x4dc5('0x9'));var fs=require('fs');var fs_extra=require(_0x4dc5('0xa'));var _=require(_0x4dc5('0xb'));var squel=require(_0x4dc5('0xc'));var crypto=require(_0x4dc5('0xd'));var jsforce=require(_0x4dc5('0xe'));var deskjs=require(_0x4dc5('0xf'));var toCsv=require(_0x4dc5('0x10'));var querystring=require(_0x4dc5('0x11'));var Papa=require('papaparse');var Redis=require(_0x4dc5('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x4dc5('0x13'));var as=require(_0x4dc5('0x14'));var hardwareService=require(_0x4dc5('0x15'));var logger=require(_0x4dc5('0x16'))(_0x4dc5('0x17'));var utils=require(_0x4dc5('0x18'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x4dc5('0x19')]=_[_0x4dc5('0x1a')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x4dc5('0x1b'))(new Redis(config[_0x4dc5('0x19')]));require(_0x4dc5('0x1c'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0x4dc5('0x1d')][_0x4dc5('0x1e')]({'port':0x232c});var client9002=jayson['client'][_0x4dc5('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x5ef38e,_0x10485b,_0x1ccc17,_0x45ec03){return new BPromise(function(_0x50827b,_0x266637){var _0x4ee8dd=_0x45ec03||client;return _0x4ee8dd[_0x4dc5('0x1f')](_0x5ef38e,_0x1ccc17)[_0x4dc5('0x20')](function(_0x26349d){logger['info']('FaxAccount,\x20%s,\x20%s',_0x10485b,_0x4dc5('0x21'));logger[_0x4dc5('0x22')](_0x4dc5('0x23'),_0x10485b,_0x4dc5('0x21'),JSON[_0x4dc5('0x24')](_0x26349d));if(_0x26349d[_0x4dc5('0x25')]){if(_0x26349d['error'][_0x4dc5('0x26')]===0x1f4){logger[_0x4dc5('0x25')](_0x4dc5('0x27'),_0x10485b,_0x26349d[_0x4dc5('0x25')][_0x4dc5('0x28')]);return _0x266637(_0x26349d[_0x4dc5('0x25')][_0x4dc5('0x28')]);}logger[_0x4dc5('0x25')]('FaxAccount,\x20%s,\x20%s',_0x10485b,_0x26349d[_0x4dc5('0x25')][_0x4dc5('0x28')]);return _0x50827b(_0x26349d[_0x4dc5('0x25')][_0x4dc5('0x28')]);}else{logger[_0x4dc5('0x29')](_0x4dc5('0x27'),_0x10485b,_0x4dc5('0x21'));_0x50827b(_0x26349d[_0x4dc5('0x2a')]['message']);}})['catch'](function(_0x11d5ef){logger[_0x4dc5('0x25')](_0x4dc5('0x27'),_0x10485b,_0x11d5ef);_0x266637(_0x11d5ef);});});}function respondWithStatusCode(_0x53e98f,_0x39de69){_0x39de69=_0x39de69||0xcc;return function(_0x4c742f){if(_0x4c742f){return _0x53e98f[_0x4dc5('0x2b')](_0x39de69);}return _0x53e98f[_0x4dc5('0x2c')](_0x39de69)[_0x4dc5('0x2d')]();};}function respondWithResult(_0x1e53a7,_0x2af058){_0x2af058=_0x2af058||0xc8;return function(_0x16b82d){if(_0x16b82d){return _0x1e53a7['status'](_0x2af058)['json'](_0x16b82d);}};}function respondWithFilteredResult(_0x2c7445,_0x25bf80){return function(_0x18f89c){if(_0x18f89c){var _0x13a8a0=typeof _0x25bf80['offset']===_0x4dc5('0x2e')&&typeof _0x25bf80[_0x4dc5('0x2f')]===_0x4dc5('0x2e');var _0x3e3c37=_0x18f89c[_0x4dc5('0x30')];var _0x4a8f32=_0x13a8a0?0x0:_0x25bf80['offset'];var _0x702244=_0x13a8a0?_0x18f89c[_0x4dc5('0x30')]:_0x25bf80[_0x4dc5('0x31')]+_0x25bf80[_0x4dc5('0x2f')];var _0x50c55a;if(_0x702244>=_0x3e3c37){_0x702244=_0x3e3c37;_0x50c55a=0xc8;}else{_0x50c55a=0xce;}_0x2c7445[_0x4dc5('0x2c')](_0x50c55a);return _0x2c7445[_0x4dc5('0x32')](_0x4dc5('0x33'),_0x4a8f32+'-'+_0x702244+'/'+_0x3e3c37)[_0x4dc5('0x34')](_0x18f89c);}return null;};}function patchUpdates(_0x5d170b){return function(_0x12fe94){try{jsonpatch[_0x4dc5('0x35')](_0x12fe94,_0x5d170b,!![]);}catch(_0x2f6e1c){return BPromise['reject'](_0x2f6e1c);}return _0x12fe94[_0x4dc5('0x36')]();};}function saveUpdates(_0x39f175,_0x1e4a86){return function(_0x51fa7b){if(_0x51fa7b){return _0x51fa7b[_0x4dc5('0x37')](_0x39f175)[_0x4dc5('0x20')](function(_0x533868){return _0x533868;});}return null;};}function removeEntity(_0x2f6958,_0x552d8d){return function(_0x38b4b){if(_0x38b4b){return _0x38b4b[_0x4dc5('0x38')]()[_0x4dc5('0x20')](function(){var _0x58af46=_0x38b4b[_0x4dc5('0x39')]({'plain':!![]});var _0x25102d=_0x4dc5('0x3a');return db[_0x4dc5('0x3b')][_0x4dc5('0x38')]({'where':{'type':_0x25102d,'resourceId':_0x58af46['id']}})[_0x4dc5('0x20')](function(){return _0x38b4b;});})[_0x4dc5('0x20')](function(){_0x2f6958[_0x4dc5('0x2c')](0xcc)[_0x4dc5('0x2d')]();});}};}function handleEntityNotFound(_0x247e47,_0x5444f6){return function(_0x3c6d2b){if(!_0x3c6d2b){_0x247e47[_0x4dc5('0x2b')](0x194);}return _0x3c6d2b;};}function handleError(_0x242cb7,_0x186093){_0x186093=_0x186093||0x1f4;return function(_0x3b8ec3){logger[_0x4dc5('0x25')](_0x3b8ec3[_0x4dc5('0x3c')]);if(_0x3b8ec3[_0x4dc5('0x3d')]){delete _0x3b8ec3[_0x4dc5('0x3d')];}_0x242cb7['status'](_0x186093)[_0x4dc5('0x3e')](_0x3b8ec3);};}exports[_0x4dc5('0x3f')]=function(_0x3e20b6,_0x141d4b){var _0x494f75={'include':[{'model':db[_0x4dc5('0x40')],'as':'mandatoryDispositionPause'}]},_0x4b1b41={},_0x369af7={'count':0x0,'rows':[]};var _0x5cf7d3=_[_0x4dc5('0x41')](db['FaxAccount'][_0x4dc5('0x42')],function(_0x488deb){return{'name':_0x488deb['fieldName'],'type':_0x488deb[_0x4dc5('0x43')]['key']};});_0x4b1b41[_0x4dc5('0x44')]=_['map'](_0x5cf7d3,_0x4dc5('0x3d'));_0x4b1b41[_0x4dc5('0x45')]=_['keys'](_0x3e20b6[_0x4dc5('0x45')]);_0x4b1b41['filters']=_['intersection'](_0x4b1b41[_0x4dc5('0x44')],_0x4b1b41[_0x4dc5('0x45')]);_0x494f75[_0x4dc5('0x46')]=_[_0x4dc5('0x47')](_0x4b1b41[_0x4dc5('0x44')],qs[_0x4dc5('0x48')](_0x3e20b6[_0x4dc5('0x45')][_0x4dc5('0x48')]));_0x494f75['attributes']=_0x494f75['attributes'][_0x4dc5('0x49')]?_0x494f75[_0x4dc5('0x46')]:_0x4b1b41['model'];if(!_0x3e20b6[_0x4dc5('0x45')]['hasOwnProperty'](_0x4dc5('0x4a'))){_0x494f75[_0x4dc5('0x2f')]=qs['limit'](_0x3e20b6['query'][_0x4dc5('0x2f')]);_0x494f75[_0x4dc5('0x31')]=qs[_0x4dc5('0x31')](_0x3e20b6[_0x4dc5('0x45')]['offset']);}_0x494f75[_0x4dc5('0x4b')]=qs[_0x4dc5('0x4c')](_0x3e20b6[_0x4dc5('0x45')]['sort']);_0x494f75[_0x4dc5('0x4d')]=qs[_0x4dc5('0x4e')](_[_0x4dc5('0x4f')](_0x3e20b6[_0x4dc5('0x45')],_0x4b1b41[_0x4dc5('0x4e')]),_0x5cf7d3);if(_0x3e20b6['query'][_0x4dc5('0x50')]){_0x494f75['where']=_[_0x4dc5('0x51')](_0x494f75[_0x4dc5('0x4d')],{'$or':_['map'](_0x5cf7d3,function(_0x38eb12){if(_0x38eb12['type']!==_0x4dc5('0x52')){var _0x1dab66={};_0x1dab66[_0x38eb12[_0x4dc5('0x3d')]]={'$like':'%'+_0x3e20b6[_0x4dc5('0x45')][_0x4dc5('0x50')]+'%'};return _0x1dab66;}})});}_0x494f75=_[_0x4dc5('0x51')]({},_0x494f75,_0x3e20b6['options']);var _0x339a5d={'where':_0x494f75[_0x4dc5('0x4d')]};return db[_0x4dc5('0x53')][_0x4dc5('0x30')](_0x339a5d)[_0x4dc5('0x20')](function(_0x984b01){_0x369af7[_0x4dc5('0x30')]=_0x984b01;if(_0x3e20b6[_0x4dc5('0x45')][_0x4dc5('0x54')]){_0x494f75[_0x4dc5('0x55')]=[{'all':!![]}];}return db[_0x4dc5('0x53')][_0x4dc5('0x56')](_0x494f75);})[_0x4dc5('0x20')](function(_0x37ee68){_0x369af7['rows']=_0x37ee68;return _0x369af7;})[_0x4dc5('0x20')](respondWithFilteredResult(_0x141d4b,_0x494f75))['catch'](handleError(_0x141d4b,null));};exports[_0x4dc5('0x57')]=function(_0x1b7fc6,_0x24d601){var _0xcb8cab={'raw':![],'where':{'id':_0x1b7fc6[_0x4dc5('0x58')]['id']},'include':[{'model':db[_0x4dc5('0x40')],'as':_0x4dc5('0x59')}]},_0x486185={};_0x486185['model']=_['keys'](db[_0x4dc5('0x53')][_0x4dc5('0x42')]);_0x486185['query']=_[_0x4dc5('0x5a')](_0x1b7fc6[_0x4dc5('0x45')]);_0x486185['filters']=_[_0x4dc5('0x47')](_0x486185[_0x4dc5('0x44')],_0x486185[_0x4dc5('0x45')]);_0xcb8cab['attributes']=_[_0x4dc5('0x47')](_0x486185[_0x4dc5('0x44')],qs[_0x4dc5('0x48')](_0x1b7fc6[_0x4dc5('0x45')][_0x4dc5('0x48')]));_0xcb8cab[_0x4dc5('0x46')]=_0xcb8cab[_0x4dc5('0x46')][_0x4dc5('0x49')]?_0xcb8cab[_0x4dc5('0x46')]:_0x486185[_0x4dc5('0x44')];if(_0x1b7fc6[_0x4dc5('0x45')][_0x4dc5('0x54')]){_0xcb8cab['include']=[{'all':!![]}];}_0xcb8cab=_[_0x4dc5('0x51')]({},_0xcb8cab,_0x1b7fc6[_0x4dc5('0x5b')]);return db['FaxAccount'][_0x4dc5('0x5c')](_0xcb8cab)[_0x4dc5('0x20')](handleEntityNotFound(_0x24d601,null))['then'](respondWithResult(_0x24d601,null))['catch'](handleError(_0x24d601,null));};exports[_0x4dc5('0x5d')]=function(_0x42fc36,_0xc4bb01){return db[_0x4dc5('0x53')][_0x4dc5('0x5d')](_0x42fc36[_0x4dc5('0x5e')],{})[_0x4dc5('0x20')](function(_0x517c56){var _0x51e2b8=_0x42fc36[_0x4dc5('0x5f')][_0x4dc5('0x39')]({'plain':!![]});if(!_0x51e2b8)throw new Error(_0x4dc5('0x60'));if(_0x51e2b8[_0x4dc5('0x61')]===_0x4dc5('0x5f')){var _0x2cbab9=_0x517c56[_0x4dc5('0x39')]({'plain':!![]});var _0x12f925=_0x4dc5('0x3a');return db[_0x4dc5('0x62')][_0x4dc5('0x5c')]({'where':{'name':_0x12f925,'userProfileId':_0x51e2b8[_0x4dc5('0x63')]},'raw':!![]})['then'](function(_0x7003e9){if(_0x7003e9&&_0x7003e9[_0x4dc5('0x64')]===0x0){return db['UserProfileResource'][_0x4dc5('0x5d')]({'name':_0x2cbab9[_0x4dc5('0x3d')],'resourceId':_0x2cbab9['id'],'type':_0x7003e9['name'],'sectionId':_0x7003e9['id']},{})[_0x4dc5('0x20')](function(){return _0x517c56;});}else{return _0x517c56;}})[_0x4dc5('0x65')](function(_0xf7c43a){logger[_0x4dc5('0x25')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xf7c43a);throw _0xf7c43a;});}return _0x517c56;})[_0x4dc5('0x20')](respondWithResult(_0xc4bb01,0xc9))[_0x4dc5('0x65')](handleError(_0xc4bb01,null));};exports['update']=function(_0x121c08,_0x3fe962){if(_0x121c08[_0x4dc5('0x5e')]['id']){delete _0x121c08[_0x4dc5('0x5e')]['id'];}return db['FaxAccount'][_0x4dc5('0x5c')]({'where':{'id':_0x121c08['params']['id']},'include':[{'model':db['Pause'],'as':_0x4dc5('0x59')}]})[_0x4dc5('0x20')](handleEntityNotFound(_0x3fe962,null))[_0x4dc5('0x20')](saveUpdates(_0x121c08['body'],null))[_0x4dc5('0x20')](respondWithResult(_0x3fe962,null))[_0x4dc5('0x65')](handleError(_0x3fe962,null));};exports[_0x4dc5('0x38')]=function(_0x5545a8,_0x2e66e0){return db['FaxAccount'][_0x4dc5('0x5c')]({'where':{'id':_0x5545a8['params']['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x2e66e0,null))['then'](removeEntity(_0x2e66e0,null))['catch'](handleError(_0x2e66e0,null));};exports['describe']=function(_0x2bf117,_0xe028d5){return db[_0x4dc5('0x53')][_0x4dc5('0x66')]()['then'](respondWithResult(_0xe028d5,null))['catch'](handleError(_0xe028d5,null));};exports[_0x4dc5('0x67')]=function(_0x39c5ee,_0x128de2,_0x1e8a5a){if(_0x39c5ee[_0x4dc5('0x5e')]['id']){delete _0x39c5ee['body']['id'];}return db['FaxAccount']['find']({'where':{'id':_0x39c5ee['params']['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x128de2,null))['then'](function(_0x57722d){if(_0x57722d){_0x39c5ee['body'][_0x4dc5('0x68')]=_0x57722d['id'];return db['Disposition'][_0x4dc5('0x5d')](_0x39c5ee['body']);}})[_0x4dc5('0x20')](respondWithResult(_0x128de2,null))['catch'](handleError(_0x128de2,null));};exports[_0x4dc5('0x69')]=function(_0x756668,_0x337395,_0x32617a){var _0x429ea6={'raw':![],'where':{}};var _0x1dfd2b={};var _0x4f7354={'count':0x0,'rows':[]};return db[_0x4dc5('0x53')][_0x4dc5('0x6a')]({'where':{'id':_0x756668[_0x4dc5('0x58')]['id']}})['then'](handleEntityNotFound(_0x337395,null))['then'](function(_0x408623){if(_0x408623){_0x1dfd2b[_0x4dc5('0x44')]=_[_0x4dc5('0x5a')](db[_0x4dc5('0x6b')][_0x4dc5('0x42')]);_0x1dfd2b[_0x4dc5('0x45')]=_['keys'](_0x756668[_0x4dc5('0x45')]);_0x1dfd2b[_0x4dc5('0x4e')]=_[_0x4dc5('0x47')](_0x1dfd2b[_0x4dc5('0x44')],_0x1dfd2b[_0x4dc5('0x45')]);_0x429ea6[_0x4dc5('0x46')]=_[_0x4dc5('0x47')](_0x1dfd2b[_0x4dc5('0x44')],qs['fields'](_0x756668[_0x4dc5('0x45')][_0x4dc5('0x48')]));_0x429ea6[_0x4dc5('0x46')]=_0x429ea6['attributes'][_0x4dc5('0x49')]?_0x429ea6['attributes']:_0x1dfd2b['model'];if(!_0x756668[_0x4dc5('0x45')][_0x4dc5('0x6c')](_0x4dc5('0x4a'))){_0x429ea6['limit']=qs[_0x4dc5('0x2f')](_0x756668['query'][_0x4dc5('0x2f')]);_0x429ea6[_0x4dc5('0x31')]=qs['offset'](_0x756668[_0x4dc5('0x45')][_0x4dc5('0x31')]);}_0x429ea6[_0x4dc5('0x4b')]=qs[_0x4dc5('0x4c')](_0x756668[_0x4dc5('0x45')][_0x4dc5('0x4c')]);_0x429ea6[_0x4dc5('0x4d')]=qs[_0x4dc5('0x4e')](_['pick'](_0x756668[_0x4dc5('0x45')],_0x1dfd2b[_0x4dc5('0x4e')]));_0x429ea6[_0x4dc5('0x4d')]['FaxAccountId']=_0x408623['id'];if(_0x756668[_0x4dc5('0x45')][_0x4dc5('0x50')]){_0x429ea6[_0x4dc5('0x4d')]=_[_0x4dc5('0x51')](_0x429ea6[_0x4dc5('0x4d')],{'$or':_[_0x4dc5('0x41')](_0x429ea6[_0x4dc5('0x46')],function(_0x46864e){var _0x1a41b3={};_0x1a41b3[_0x46864e]={'$like':'%'+_0x756668[_0x4dc5('0x45')][_0x4dc5('0x50')]+'%'};return _0x1a41b3;})});}_0x429ea6=_[_0x4dc5('0x51')]({},_0x429ea6,_0x756668[_0x4dc5('0x5b')]);return db['Disposition'][_0x4dc5('0x30')]({'where':_0x429ea6[_0x4dc5('0x4d')]})[_0x4dc5('0x20')](function(_0x4ba688){_0x4f7354[_0x4dc5('0x30')]=_0x4ba688;if(_0x756668['query'][_0x4dc5('0x54')]){_0x429ea6[_0x4dc5('0x55')]=[{'all':!![]}];}return db['Disposition'][_0x4dc5('0x56')](_0x429ea6);})[_0x4dc5('0x20')](function(_0x3f97a6){_0x4f7354['rows']=_0x3f97a6;return _0x4f7354;});}})[_0x4dc5('0x20')](respondWithFilteredResult(_0x337395,_0x429ea6))[_0x4dc5('0x65')](handleError(_0x337395,null));};exports[_0x4dc5('0x6d')]=function(_0x5ec462,_0x5acf18,_0x5a3262){return db[_0x4dc5('0x53')][_0x4dc5('0x5c')]({'where':{'id':_0x5ec462[_0x4dc5('0x58')]['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x5acf18,null))[_0x4dc5('0x20')](function(_0x4b5ed2){if(_0x4b5ed2){return _0x4b5ed2[_0x4dc5('0x6d')](_0x5ec462[_0x4dc5('0x45')][_0x4dc5('0x6e')]);}})[_0x4dc5('0x20')](respondWithStatusCode(_0x5acf18,null))[_0x4dc5('0x65')](handleError(_0x5acf18,null));};exports[_0x4dc5('0x6f')]=function(_0x125cf4,_0x5ed515,_0x3aee04){if(_0x125cf4[_0x4dc5('0x5e')]['id']){delete _0x125cf4[_0x4dc5('0x5e')]['id'];}return db[_0x4dc5('0x53')][_0x4dc5('0x5c')]({'where':{'id':_0x125cf4[_0x4dc5('0x58')]['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x5ed515,null))[_0x4dc5('0x20')](function(_0x9a503b){if(_0x9a503b){_0x125cf4[_0x4dc5('0x5e')][_0x4dc5('0x68')]=_0x9a503b['id'];return db[_0x4dc5('0x70')][_0x4dc5('0x5d')](_0x125cf4[_0x4dc5('0x5e')]);}})[_0x4dc5('0x20')](respondWithResult(_0x5ed515,null))[_0x4dc5('0x65')](handleError(_0x5ed515,null));};exports[_0x4dc5('0x71')]=function(_0x16cf0e,_0x4d6051,_0x50b9c1){var _0x5c8352={'raw':![],'where':{}};var _0x231bc5={};var _0x4293ae={'count':0x0,'rows':[]};return db[_0x4dc5('0x53')][_0x4dc5('0x6a')]({'where':{'id':_0x16cf0e[_0x4dc5('0x58')]['id']}})['then'](handleEntityNotFound(_0x4d6051,null))[_0x4dc5('0x20')](function(_0x3b3c2a){if(_0x3b3c2a){_0x231bc5[_0x4dc5('0x44')]=_[_0x4dc5('0x5a')](db[_0x4dc5('0x70')]['rawAttributes']);_0x231bc5[_0x4dc5('0x45')]=_['keys'](_0x16cf0e['query']);_0x231bc5[_0x4dc5('0x4e')]=_[_0x4dc5('0x47')](_0x231bc5[_0x4dc5('0x44')],_0x231bc5['query']);_0x5c8352['attributes']=_['intersection'](_0x231bc5[_0x4dc5('0x44')],qs[_0x4dc5('0x48')](_0x16cf0e[_0x4dc5('0x45')][_0x4dc5('0x48')]));_0x5c8352[_0x4dc5('0x46')]=_0x5c8352[_0x4dc5('0x46')][_0x4dc5('0x49')]?_0x5c8352['attributes']:_0x231bc5['model'];if(!_0x16cf0e[_0x4dc5('0x45')]['hasOwnProperty']('nolimit')){_0x5c8352[_0x4dc5('0x2f')]=qs[_0x4dc5('0x2f')](_0x16cf0e[_0x4dc5('0x45')][_0x4dc5('0x2f')]);_0x5c8352['offset']=qs[_0x4dc5('0x31')](_0x16cf0e[_0x4dc5('0x45')]['offset']);}_0x5c8352[_0x4dc5('0x4b')]=qs[_0x4dc5('0x4c')](_0x16cf0e['query'][_0x4dc5('0x4c')]);_0x5c8352[_0x4dc5('0x4d')]=qs[_0x4dc5('0x4e')](_['pick'](_0x16cf0e[_0x4dc5('0x45')],_0x231bc5[_0x4dc5('0x4e')]));_0x5c8352['where'][_0x4dc5('0x68')]=_0x3b3c2a['id'];if(_0x16cf0e[_0x4dc5('0x45')][_0x4dc5('0x50')]){_0x5c8352[_0x4dc5('0x4d')]=_[_0x4dc5('0x51')](_0x5c8352['where'],{'$or':_['map'](_0x5c8352[_0x4dc5('0x46')],function(_0x5a7f77){var _0x1b3316={};_0x1b3316[_0x5a7f77]={'$like':'%'+_0x16cf0e[_0x4dc5('0x45')][_0x4dc5('0x50')]+'%'};return _0x1b3316;})});}_0x5c8352=_['merge']({},_0x5c8352,_0x16cf0e['options']);return db[_0x4dc5('0x70')][_0x4dc5('0x30')]({'where':_0x5c8352[_0x4dc5('0x4d')]})[_0x4dc5('0x20')](function(_0x8b5217){_0x4293ae[_0x4dc5('0x30')]=_0x8b5217;if(_0x16cf0e['query'][_0x4dc5('0x54')]){_0x5c8352[_0x4dc5('0x55')]=[{'all':!![]}];}return db[_0x4dc5('0x70')]['findAll'](_0x5c8352);})[_0x4dc5('0x20')](function(_0xd02a02){_0x4293ae[_0x4dc5('0x72')]=_0xd02a02;return _0x4293ae;});}})['then'](respondWithFilteredResult(_0x4d6051,_0x5c8352))[_0x4dc5('0x65')](handleError(_0x4d6051,null));};exports[_0x4dc5('0x73')]=function(_0x4917ee,_0x2feeff,_0x3807ee){return db[_0x4dc5('0x53')][_0x4dc5('0x5c')]({'where':{'id':_0x4917ee[_0x4dc5('0x58')]['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x2feeff,null))[_0x4dc5('0x20')](function(_0x2da198){if(_0x2da198){return _0x2da198[_0x4dc5('0x73')](_0x4917ee[_0x4dc5('0x45')][_0x4dc5('0x6e')]);}})[_0x4dc5('0x20')](respondWithStatusCode(_0x2feeff,null))[_0x4dc5('0x65')](handleError(_0x2feeff,null));};exports[_0x4dc5('0x74')]=function(_0x1d9ae4,_0x35faf3,_0x5531b3){return db[_0x4dc5('0x75')][_0x4dc5('0x5c')]({'where':{'id':_0x1d9ae4[_0x4dc5('0x58')]['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x35faf3,null))[_0x4dc5('0x20')](function(_0x3fde66){if(_0x3fde66){return _0x3fde66[_0x4dc5('0x74')](_0x1d9ae4[_0x4dc5('0x5e')][_0x4dc5('0x6e')],_[_0x4dc5('0x76')](_0x1d9ae4[_0x4dc5('0x5e')],['ids','id'])||{});}})[_0x4dc5('0x20')](respondWithResult(_0x35faf3,null))['catch'](handleError(_0x35faf3,null));};exports[_0x4dc5('0x77')]=function(_0x39aabe,_0x44d3cb,_0x388d98){var _0x30c107={'raw':![],'where':{}};var _0x20b0e7={};var _0x589f8e={'count':0x0,'rows':[]};return db[_0x4dc5('0x53')][_0x4dc5('0x6a')]({'where':{'id':_0x39aabe[_0x4dc5('0x58')]['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x44d3cb,null))[_0x4dc5('0x20')](function(_0x301c28){if(_0x301c28){_0x20b0e7[_0x4dc5('0x44')]=_[_0x4dc5('0x5a')](db[_0x4dc5('0x75')][_0x4dc5('0x42')]);_0x20b0e7['query']=_[_0x4dc5('0x5a')](_0x39aabe[_0x4dc5('0x45')]);_0x20b0e7[_0x4dc5('0x4e')]=_[_0x4dc5('0x47')](_0x20b0e7[_0x4dc5('0x44')],_0x20b0e7[_0x4dc5('0x45')]);_0x30c107['attributes']=_[_0x4dc5('0x47')](_0x20b0e7['model'],qs[_0x4dc5('0x48')](_0x39aabe[_0x4dc5('0x45')][_0x4dc5('0x48')]));_0x30c107[_0x4dc5('0x46')]=_0x30c107[_0x4dc5('0x46')][_0x4dc5('0x49')]?_0x30c107[_0x4dc5('0x46')]:_0x20b0e7[_0x4dc5('0x44')];if(!_0x39aabe[_0x4dc5('0x45')][_0x4dc5('0x6c')](_0x4dc5('0x4a'))){_0x30c107[_0x4dc5('0x2f')]=qs[_0x4dc5('0x2f')](_0x39aabe[_0x4dc5('0x45')][_0x4dc5('0x2f')]);_0x30c107[_0x4dc5('0x31')]=qs[_0x4dc5('0x31')](_0x39aabe[_0x4dc5('0x45')]['offset']);}_0x30c107[_0x4dc5('0x4b')]=qs['sort'](_0x39aabe[_0x4dc5('0x45')][_0x4dc5('0x4c')]);_0x30c107[_0x4dc5('0x4d')]=qs[_0x4dc5('0x4e')](_[_0x4dc5('0x4f')](_0x39aabe['query'],_0x20b0e7[_0x4dc5('0x4e')]));_0x30c107[_0x4dc5('0x4d')][_0x4dc5('0x68')]=_0x301c28['id'];if(_0x39aabe[_0x4dc5('0x45')]['filter']){_0x30c107[_0x4dc5('0x4d')]=_['merge'](_0x30c107['where'],{'$or':_[_0x4dc5('0x41')](_0x30c107[_0x4dc5('0x46')],function(_0x31078b){var _0x100c87={};_0x100c87[_0x31078b]={'$like':'%'+_0x39aabe[_0x4dc5('0x45')]['filter']+'%'};return _0x100c87;})});}_0x30c107=_['merge']({},_0x30c107,_0x39aabe[_0x4dc5('0x5b')]);return db[_0x4dc5('0x75')][_0x4dc5('0x30')]({'where':_0x30c107[_0x4dc5('0x4d')]})['then'](function(_0x1b3bb0){_0x589f8e['count']=_0x1b3bb0;if(_0x39aabe[_0x4dc5('0x45')]['includeAll']){_0x30c107[_0x4dc5('0x55')]=[{'model':db[_0x4dc5('0x78')],'as':_0x4dc5('0x79'),'required':![]},{'model':db['User'],'as':'Owner','attributes':[_0x4dc5('0x3d'),'fullname',_0x4dc5('0x7a')],'required':![]},{'model':db['Tag'],'as':_0x4dc5('0x7b'),'attributes':['id',_0x4dc5('0x3d'),_0x4dc5('0x7c')],'where':_0x39aabe[_0x4dc5('0x45')][_0x4dc5('0x7d')]?{'id':_0x39aabe[_0x4dc5('0x45')][_0x4dc5('0x7d')]}:undefined,'required':_0x39aabe[_0x4dc5('0x45')]['tag']?!![]:![]}];}return db[_0x4dc5('0x75')][_0x4dc5('0x56')](_0x30c107);})[_0x4dc5('0x20')](function(_0x2ad131){_0x589f8e[_0x4dc5('0x72')]=_0x2ad131;return _0x589f8e;});}})[_0x4dc5('0x20')](respondWithFilteredResult(_0x44d3cb,_0x30c107))[_0x4dc5('0x65')](handleError(_0x44d3cb,null));};exports[_0x4dc5('0x7e')]=function(_0x291350,_0x4f3ce5){var _0x410bb5=_0x291350['params']['id'];var _0x1954e5=_0x291350[_0x4dc5('0x5e')];var _0x42ace1=0xc8;var _0x1a8c78=null;return db[_0x4dc5('0x7f')][_0x4dc5('0x80')]({'isolationLevel':db['sequelize']['Transaction']['ISOLATION_LEVELS']['READ_COMMITTED']},function(_0x35e90){return db[_0x4dc5('0x53')]['findOne']({'where':{'id':_0x410bb5},'transaction':_0x35e90})[_0x4dc5('0x20')](function(_0x2f512a){if(_0x2f512a){return db[_0x4dc5('0x81')][_0x4dc5('0x38')]({'where':{'FaxAccountId':_0x410bb5},'transaction':_0x35e90})[_0x4dc5('0x20')](function(){var _0x11c83d=_['map'](_0x1954e5,function(_0x1371e0){_0x1371e0['FaxAccountId']=_0x410bb5;return _0x1371e0;});return db['FaxApplication'][_0x4dc5('0x82')](_0x11c83d,{'transaction':_0x35e90});});}else{_0x42ace1=0x194;_0x1a8c78=[];}});})['then'](function(){if(_0x42ace1!==0x194){return db[_0x4dc5('0x81')]['findAndCountAll']({'where':{'FaxAccountId':_0x410bb5},'order':_0x4dc5('0x83')})['then'](function(_0x9b571a){_0x1a8c78=_0x9b571a;});}})['catch'](function(_0x5da81d){_0x42ace1=0x1f4;logger['error'](_0x5da81d[_0x4dc5('0x3c')]);if(_0x5da81d[_0x4dc5('0x3d')]){delete _0x5da81d[_0x4dc5('0x3d')];}_0x1a8c78=_0x5da81d;})['finally'](function(){if(_0x1a8c78===null){_0x4f3ce5['sendStatus'](_0x42ace1);}else{if(_0x42ace1===0x1f4){_0x4f3ce5[_0x4dc5('0x2c')](_0x42ace1)[_0x4dc5('0x3e')](_0x1a8c78);}else{_0x4f3ce5['status'](_0x42ace1)['json'](_0x1a8c78);}}});};exports[_0x4dc5('0x84')]=function(_0x59d1a2,_0x20d2a4,_0x42d080){var _0x70a9e5={};var _0x57f9a3={};var _0x53806c;var _0x157166;return db['FaxAccount'][_0x4dc5('0x6a')]({'where':{'id':_0x59d1a2['params']['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x20d2a4,null))[_0x4dc5('0x20')](function(_0x28e14c){if(_0x28e14c){_0x53806c=_0x28e14c;_0x57f9a3['model']=_[_0x4dc5('0x5a')](db[_0x4dc5('0x81')]['rawAttributes']);_0x57f9a3[_0x4dc5('0x45')]=_[_0x4dc5('0x5a')](_0x59d1a2[_0x4dc5('0x45')]);_0x57f9a3[_0x4dc5('0x4e')]=_[_0x4dc5('0x47')](_0x57f9a3[_0x4dc5('0x44')],_0x57f9a3[_0x4dc5('0x45')]);_0x70a9e5[_0x4dc5('0x46')]=_[_0x4dc5('0x47')](_0x57f9a3[_0x4dc5('0x44')],qs[_0x4dc5('0x48')](_0x59d1a2['query'][_0x4dc5('0x48')]));_0x70a9e5['attributes']=_0x70a9e5[_0x4dc5('0x46')]['length']?_0x70a9e5[_0x4dc5('0x46')]:_0x57f9a3['model'];_0x70a9e5[_0x4dc5('0x4b')]=qs[_0x4dc5('0x4c')](_0x59d1a2[_0x4dc5('0x45')][_0x4dc5('0x4c')]);_0x70a9e5[_0x4dc5('0x4d')]=qs[_0x4dc5('0x4e')](_[_0x4dc5('0x4f')](_0x59d1a2[_0x4dc5('0x45')],_0x57f9a3[_0x4dc5('0x4e')]));if(_0x59d1a2[_0x4dc5('0x45')][_0x4dc5('0x50')]){_0x70a9e5[_0x4dc5('0x4d')]=_[_0x4dc5('0x51')](_0x70a9e5[_0x4dc5('0x4d')],{'$or':_['map'](_0x70a9e5[_0x4dc5('0x46')],function(_0x4ca8a0){var _0x55a472={};_0x55a472[_0x4ca8a0]={'$like':'%'+_0x59d1a2['query'][_0x4dc5('0x50')]+'%'};return _0x55a472;})});}_0x70a9e5=_[_0x4dc5('0x51')]({},_0x70a9e5,_0x59d1a2[_0x4dc5('0x5b')]);return _0x53806c[_0x4dc5('0x84')](_0x70a9e5);}})[_0x4dc5('0x20')](function(_0x537eaa){if(_0x537eaa){_0x157166=_0x537eaa[_0x4dc5('0x49')];if(!_0x59d1a2['query']['hasOwnProperty']('nolimit')){_0x70a9e5[_0x4dc5('0x2f')]=qs[_0x4dc5('0x2f')](_0x59d1a2[_0x4dc5('0x45')][_0x4dc5('0x2f')]);_0x70a9e5['offset']=qs['offset'](_0x59d1a2[_0x4dc5('0x45')][_0x4dc5('0x31')]);}return _0x53806c[_0x4dc5('0x84')](_0x70a9e5);}})[_0x4dc5('0x20')](function(_0x14bd93){if(_0x14bd93){return _0x14bd93?{'count':_0x157166,'rows':_0x14bd93}:null;}})[_0x4dc5('0x20')](respondWithResult(_0x20d2a4,null))[_0x4dc5('0x65')](handleError(_0x20d2a4,null));};function Extension(_0x45092b,_0x94f887,_0x249e81,_0x53cf8d){this[_0x4dc5('0x85')]='from-voip-provider';this[_0x4dc5('0x86')]=_0x45092b[_0x4dc5('0x87')];this[_0x4dc5('0x88')]=_0x53cf8d;this[_0x4dc5('0x43')]=_0x4dc5('0x89');this[_0x4dc5('0x8a')]=_0x4dc5('0x8b');this[_0x4dc5('0x68')]=_0x45092b['id'];this['priority']=_0x94f887;this[_0x4dc5('0x8c')]=_0x249e81;}function createExtensionsReciveFax(_0x5eb84a){var _0x35507f=0x1;var _0x19dd48=[];_0x19dd48[_0x4dc5('0x8d')](new Extension(_0x5eb84a,_0x35507f,'',_0x4dc5('0x8e')));_0x35507f+=0x1;_0x19dd48['push'](new Extension(_0x5eb84a,_0x35507f,_0x4dc5('0x8f'),_0x4dc5('0x90')));_0x35507f+=0x1;for(var _0x54a658 in _0x5eb84a){if(_0x5eb84a[_0x4dc5('0x6c')](_0x54a658)&&(_0x54a658===_0x4dc5('0x91')||_0x54a658===_0x4dc5('0x87')||_0x54a658===_0x4dc5('0x92')||_0x54a658==='faxdetect'||_0x54a658===_0x4dc5('0x93')||_0x54a658==='maxrate'||_0x54a658===_0x4dc5('0x94')||_0x54a658===_0x4dc5('0x95')||_0x54a658==='t38timeout')){_0x19dd48['push'](new Extension(_0x5eb84a,_0x35507f,'FAXOPT('+_0x54a658+')='+_0x5eb84a[_0x54a658],_0x4dc5('0x90')));_0x35507f+=0x1;}}_0x19dd48[_0x4dc5('0x8d')](new Extension(_0x5eb84a,_0x35507f,'6',_0x4dc5('0x96')));_0x35507f+=0x1;_0x19dd48[_0x4dc5('0x8d')](new Extension(_0x5eb84a,_0x35507f,'/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',_0x4dc5('0x97')));_0x35507f=0x0;return _0x19dd48;}exports[_0x4dc5('0x98')]=function(_0x1703f0,_0x5ae7d9,_0x1b5018){var _0x5b01b2;return db[_0x4dc5('0x7f')]['transaction'](function(_0x4a7cf1){return db['FaxAccount'][_0x4dc5('0x5d')](_0x1703f0[_0x4dc5('0x5e')],{'transaction':_0x4a7cf1})[_0x4dc5('0x20')](function(_0x213a1d){_0x5b01b2=_0x213a1d[_0x4dc5('0x39')]({'plain':!![]});return db[_0x4dc5('0x99')][_0x4dc5('0x82')](createExtensionsReciveFax(_0x5b01b2),{'transaction':_0x4a7cf1});});})['then'](function(){return _0x5b01b2;})['then'](respondWithResult(_0x5ae7d9,null))[_0x4dc5('0x65')](handleError(_0x5ae7d9,null));};exports[_0x4dc5('0x9a')]=function(_0x340dbd,_0x5a25d4,_0x379c78){var _0x306761;return db[_0x4dc5('0x7f')][_0x4dc5('0x80')](function(_0x591fc5){return db['FaxAccount'][_0x4dc5('0x37')](_0x340dbd['body'],{'where':{'id':_0x340dbd[_0x4dc5('0x5e')]['id']},'transaction':_0x591fc5})[_0x4dc5('0x20')](function(_0x568fdb){return db[_0x4dc5('0x99')][_0x4dc5('0x38')]({'where':{'FaxAccountId':_0x340dbd[_0x4dc5('0x5e')]['id']},'transaction':_0x591fc5})[_0x4dc5('0x20')](function(_0x150fa9){return db[_0x4dc5('0x99')][_0x4dc5('0x82')](createExtensionsReciveFax(_[_0x4dc5('0x76')](_0x340dbd[_0x4dc5('0x5e')],['tech',_0x4dc5('0x9b'),'createdAt',_0x4dc5('0x9c'),_0x4dc5('0x9d'),_0x4dc5('0x9e')])),{'transaction':_0x591fc5});});});})[_0x4dc5('0x20')](function(){return db[_0x4dc5('0x53')][_0x4dc5('0x9f')](_0x340dbd[_0x4dc5('0x5e')]['id']);})[_0x4dc5('0x20')](respondWithResult(_0x5a25d4,null))[_0x4dc5('0x65')](handleError(_0x5a25d4,null));};exports['getMessages']=function(_0x24e6d0,_0x3b39b6,_0x209542){var _0x4b911a={'raw':!![],'where':{}};var _0x2e2b63={};var _0x47d27d={'count':0x0,'rows':[]};return db[_0x4dc5('0x53')][_0x4dc5('0x6a')]({'where':{'id':_0x24e6d0[_0x4dc5('0x58')]['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x3b39b6,null))[_0x4dc5('0x20')](function(_0x3eb77e){if(_0x3eb77e){_0x2e2b63[_0x4dc5('0x44')]=_[_0x4dc5('0x5a')](db[_0x4dc5('0xa0')][_0x4dc5('0x42')]);_0x2e2b63[_0x4dc5('0x45')]=_[_0x4dc5('0x5a')](_0x24e6d0[_0x4dc5('0x45')]);_0x2e2b63['filters']=_['intersection'](_0x2e2b63['model'],_0x2e2b63[_0x4dc5('0x45')]);_0x4b911a['attributes']=_[_0x4dc5('0x47')](_0x2e2b63['model'],qs[_0x4dc5('0x48')](_0x24e6d0['query']['fields']));_0x4b911a[_0x4dc5('0x46')]=_0x4b911a[_0x4dc5('0x46')][_0x4dc5('0x49')]?_0x4b911a[_0x4dc5('0x46')]:_0x2e2b63[_0x4dc5('0x44')];if(!_0x24e6d0[_0x4dc5('0x45')][_0x4dc5('0x6c')](_0x4dc5('0x4a'))){_0x4b911a[_0x4dc5('0x2f')]=qs[_0x4dc5('0x2f')](_0x24e6d0['query']['limit']);_0x4b911a[_0x4dc5('0x31')]=qs['offset'](_0x24e6d0[_0x4dc5('0x45')][_0x4dc5('0x31')]);}_0x4b911a[_0x4dc5('0x4b')]=qs[_0x4dc5('0x4c')](_0x24e6d0['query'][_0x4dc5('0x4c')]);_0x4b911a[_0x4dc5('0x4d')]=qs['filters'](_['pick'](_0x24e6d0[_0x4dc5('0x45')],_0x2e2b63[_0x4dc5('0x4e')]));_0x4b911a[_0x4dc5('0x4d')][_0x4dc5('0x68')]=_0x3eb77e['id'];if(_0x24e6d0[_0x4dc5('0x45')][_0x4dc5('0x50')]){_0x4b911a[_0x4dc5('0x4d')]=_[_0x4dc5('0x51')](_0x4b911a['where'],{'$or':_[_0x4dc5('0x41')](_0x4b911a['attributes'],function(_0x43d01b){var _0x119c0c={};_0x119c0c[_0x43d01b]={'$like':'%'+_0x24e6d0[_0x4dc5('0x45')][_0x4dc5('0x50')]+'%'};return _0x119c0c;})});}if(_0x24e6d0[_0x4dc5('0x45')][_0x4dc5('0xa1')]){var _0x1935cd=_0x24e6d0[_0x4dc5('0x45')][_0x4dc5('0xa1')][_0x4dc5('0xa2')](',');var _0x19357a={};_0x19357a[_0x1935cd[0x0]]={'$gte':moment(_0x1935cd[0x1])[_0x4dc5('0xa3')](_0x4dc5('0xa4'))};_0x4b911a[_0x4dc5('0x4d')]=_['merge'](_0x4b911a[_0x4dc5('0x4d')],_0x19357a);}_0x4b911a=_[_0x4dc5('0x51')]({},_0x4b911a,_0x24e6d0[_0x4dc5('0x5b')]);return db[_0x4dc5('0xa0')][_0x4dc5('0x30')]({'where':_0x4b911a[_0x4dc5('0x4d')]})[_0x4dc5('0x20')](function(_0x4a6f15){_0x47d27d[_0x4dc5('0x30')]=_0x4a6f15;if(_0x24e6d0['query'][_0x4dc5('0x54')]){_0x4b911a[_0x4dc5('0x55')]=[{'all':!![]}];}return db[_0x4dc5('0xa0')]['findAll'](_0x4b911a);})[_0x4dc5('0x20')](function(_0x538252){_0x47d27d[_0x4dc5('0x72')]=_0x538252;return _0x47d27d;});}})['then'](respondWithFilteredResult(_0x3b39b6,_0x4b911a))[_0x4dc5('0x65')](handleError(_0x3b39b6,null));};exports[_0x4dc5('0x3e')]=function(_0x2bebe6,_0x3c9ddd,_0x2a8bac){var _0x2cab83,_0x3efbea={},_0x404f9f;if(_0x2bebe6[_0x4dc5('0x5e')]['to']){_0x404f9f=_0x2bebe6[_0x4dc5('0x5e')]['to'][0x0];}return db[_0x4dc5('0x53')][_0x4dc5('0x5c')]({'where':{'id':_0x2bebe6[_0x4dc5('0x58')]['id']},'include':[{'model':db[_0x4dc5('0xa5')],'as':_0x4dc5('0xa6'),'include':[{'model':db['CmContact'],'as':_0x4dc5('0xa7'),'where':{'fax':_0x404f9f},'limit':0x1,'order':[[_0x4dc5('0x9c'),'DESC']]}]}]})[_0x4dc5('0x20')](handleEntityNotFound(_0x3c9ddd,null))[_0x4dc5('0x20')](function(_0x471816){_0x2cab83=_0x471816;if(_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')]&&_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][_0x4dc5('0x49')]){for(var _0x129cd8=0x0;_0x129cd8<_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][_0x4dc5('0x49')];_0x129cd8+=0x1){_0x2bebe6[_0x4dc5('0x5e')]['attachments'][_0x129cd8]={'filename':_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][_0x129cd8][_0x4dc5('0x3d')],'id':_0x2bebe6[_0x4dc5('0x5e')]['attachments'][_0x129cd8]['id'],'path':path[_0x4dc5('0xa9')](config[_0x4dc5('0xaa')],_0x4dc5('0xab'),_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][_0x129cd8][_0x4dc5('0xac')])};}}return respondWithRpcPromise(_0x4dc5('0xad'),_0x4dc5('0xad'),{'FaxAccountId':_[_0x4dc5('0xae')](_0x2bebe6['params']['id'])?undefined:_0x2bebe6[_0x4dc5('0x58')]['id'],'path':_['isNil'](_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][0x0]['path'])?undefined:_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][0x0][_0x4dc5('0xaf')],'fax':_[_0x4dc5('0xae')](_0x2bebe6['body']['to'][0x0])?undefined:_0x2bebe6[_0x4dc5('0x5e')]['to'][0x0]},client9002);})[_0x4dc5('0x20')](function(){if(_0x2cab83){if(_[_0x4dc5('0xae')](_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xb0')])){_0x2bebe6[_0x4dc5('0x5e')]['from']=util['format'](_0x4dc5('0xb1'),_0x2cab83[_0x4dc5('0x3d')],_0x2cab83[_0x4dc5('0xb2')]);}if(_0x2cab83[_0x4dc5('0xa6')]){if(_0x2cab83[_0x4dc5('0xa6')][_0x4dc5('0xa7')][_0x4dc5('0x49')]){return _0x2cab83[_0x4dc5('0xa6')][_0x4dc5('0xa7')][0x0];}else{return db['CmContact']['create'](_[_0x4dc5('0x1a')](_0x2bebe6[_0x4dc5('0x5e')],{'firstName':_0x2bebe6[_0x4dc5('0x5e')]['to'][0x0],'phone':_0x2bebe6[_0x4dc5('0x5e')]['to'][0x0],'fax':_0x2bebe6[_0x4dc5('0x5e')]['to'][0x0],'ListId':_0x2cab83[_0x4dc5('0x9e')]}));}}else{throw new Error(_0x4dc5('0xb3'));}}else{throw new Error('Send\x20Fax\x20failed');}})[_0x4dc5('0x20')](function(_0x55bc88){if(_0x55bc88){return db[_0x4dc5('0x75')]['find']({'where':{'ContactId':_0x55bc88['id'],'closed':![],'FaxAccountId':_0x2cab83['id']}})[_0x4dc5('0x20')](function(_0x28ad20){if(_0x28ad20){return[_0x28ad20,![]];}return db[_0x4dc5('0x75')][_0x4dc5('0x5d')]({'UserId':_0x2bebe6[_0x4dc5('0x5f')]['id'],'ContactId':_0x55bc88['id'],'FaxAccountId':_0x2cab83['id'],'fax':_0x2bebe6[_0x4dc5('0x5e')]['to'][0x0],'firstMsgDirection':'out','Messages':[_[_0x4dc5('0x51')](_0x2bebe6[_0x4dc5('0x5e')],{'read':![],'body':_0x2bebe6['body'][_0x4dc5('0xa8')][0x0][_0x4dc5('0xb4')],'FaxAccountId':_0x2cab83['id'],'UserId':_0x2bebe6['user']['id'],'ContactId':_0x55bc88['id'],'AttachmentId':_0x2bebe6[_0x4dc5('0x5e')]['attachments'][0x0]['id']})]},{'include':[{'model':db[_0x4dc5('0xa0')],'as':_0x4dc5('0xb5')}]})[_0x4dc5('0x20')](function(_0x5d1566){return[_0x5d1566,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})[_0x4dc5('0xb6')](function(_0x6d4e0b,_0xa3587a){if(_0xa3587a){return _0x6d4e0b;}return db[_0x4dc5('0xa0')][_0x4dc5('0x5d')]({'direction':_0x4dc5('0xb7'),'read':![],'body':_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][0x0][_0x4dc5('0xb4')],'FaxAccountId':_0x2cab83['id'],'FaxInteractionId':_0x6d4e0b['id'],'UserId':_0x2bebe6['user']['id'],'ContactId':_0x6d4e0b['ContactId'],'AttachmentId':_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][0x0]['id']})['then'](function(_0x2bbb8e){_0x6d4e0b[_0x4dc5('0xb8')][_0x4dc5('0xb5')]=[];_0x6d4e0b['dataValues'][_0x4dc5('0xb5')][_0x4dc5('0x8d')](_0x2bbb8e[_0x4dc5('0xb8')]);return _0x6d4e0b;});})[_0x4dc5('0x20')](function(_0x28bea6){respondWithRpcPromise(_0x4dc5('0xb9'),_0x4dc5('0xb9'),{'FaxAccountId':_[_0x4dc5('0xae')](_0x2bebe6[_0x4dc5('0x58')]['id'])?undefined:_0x2bebe6['params']['id'],'path':_[_0x4dc5('0xae')](_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][0x0][_0x4dc5('0xaf')])?undefined:_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][0x0]['path'],'fax':_[_0x4dc5('0xae')](_0x2bebe6['body']['to'][0x0])?undefined:_0x2bebe6['body']['to'][0x0],'AttachmentId':_0x2bebe6[_0x4dc5('0x5e')][_0x4dc5('0xa8')][0x0]['id']},client9002)[_0x4dc5('0x20')](function(_0x27556e){logger[_0x4dc5('0x29')]('SendFaxRpc,\x20%s',_0x27556e);})[_0x4dc5('0x65')](function(_0x233d51){logger[_0x4dc5('0x29')](_0x4dc5('0xba'),_0x233d51);});return _0x28bea6;})[_0x4dc5('0x20')](respondWithResult(_0x3c9ddd,null))[_0x4dc5('0x65')](handleError(_0x3c9ddd,null));};exports[_0x4dc5('0xbb')]=function(_0x93dfaf,_0x35940b,_0x2bfb6e){return db[_0x4dc5('0x53')][_0x4dc5('0x5c')]({'where':{'id':_0x93dfaf[_0x4dc5('0x58')]['id']}})['then'](handleEntityNotFound(_0x35940b,null))[_0x4dc5('0x20')](function(_0x17d70e){if(_0x17d70e){return _0x17d70e['addAgents'](_0x93dfaf['body']['ids'],_[_0x4dc5('0x76')](_0x93dfaf[_0x4dc5('0x5e')],[_0x4dc5('0x6e'),'id'])||{})[_0x4dc5('0xb6')](function(_0x5d071a){for(var _0x47980b=0x0;_0x47980b<_0x93dfaf[_0x4dc5('0x5e')][_0x4dc5('0x6e')][_0x4dc5('0x49')];_0x47980b+=0x1){socket[_0x4dc5('0xbc')](_0x4dc5('0xbd'),{'UserId':Number(_0x93dfaf[_0x4dc5('0x5e')][_0x4dc5('0x6e')][_0x47980b]),'FaxAccountId':Number(_0x93dfaf['params']['id'])});}return _0x5d071a;});}})[_0x4dc5('0x20')](respondWithResult(_0x35940b,null))[_0x4dc5('0x65')](handleError(_0x35940b,null));};exports['removeAgents']=function(_0x24ad90,_0x1b5100,_0x3aedf9){return db[_0x4dc5('0x53')][_0x4dc5('0x5c')]({'where':{'id':_0x24ad90[_0x4dc5('0x58')]['id']}})[_0x4dc5('0x20')](handleEntityNotFound(_0x1b5100,null))[_0x4dc5('0x20')](function(_0xc6bf9e){if(_0xc6bf9e){return _0xc6bf9e[_0x4dc5('0xbe')](_0x24ad90[_0x4dc5('0x45')][_0x4dc5('0x6e')])[_0x4dc5('0x20')](function(){if(_[_0x4dc5('0xbf')](_0x24ad90[_0x4dc5('0x45')][_0x4dc5('0x6e')])){for(var _0x388c72=0x0;_0x388c72<_0x24ad90[_0x4dc5('0x45')][_0x4dc5('0x6e')][_0x4dc5('0x49')];_0x388c72+=0x1){socket[_0x4dc5('0xbc')](_0x4dc5('0xc0'),{'UserId':Number(_0x24ad90['query']['ids'][_0x388c72]),'FaxAccountId':Number(_0x24ad90[_0x4dc5('0x58')]['id'])});}}else{socket['emit'](_0x4dc5('0xc0'),{'UserId':Number(_0x24ad90['query'][_0x4dc5('0x6e')]),'FaxAccountId':Number(_0x24ad90[_0x4dc5('0x58')]['id'])});}});}})[_0x4dc5('0x20')](respondWithStatusCode(_0x1b5100,null))[_0x4dc5('0x65')](handleError(_0x1b5100,null));};exports[_0x4dc5('0xc1')]=function(_0x3fab35,_0xd003c7,_0x2b0d8b){var _0x4161b6={};var _0x5cb34a={};var _0x5a26b8;var _0x43ea9d;return db[_0x4dc5('0x53')]['findOne']({'where':{'id':_0x3fab35[_0x4dc5('0x58')]['id']}})['then'](handleEntityNotFound(_0xd003c7,null))[_0x4dc5('0x20')](function(_0x4b1d91){if(_0x4b1d91){_0x5a26b8=_0x4b1d91;_0x5cb34a[_0x4dc5('0x44')]=_[_0x4dc5('0x5a')](db[_0x4dc5('0xc2')][_0x4dc5('0x42')]);_0x5cb34a[_0x4dc5('0x45')]=_[_0x4dc5('0x5a')](_0x3fab35['query']);_0x5cb34a['filters']=_['intersection'](_0x5cb34a['model'],_0x5cb34a[_0x4dc5('0x45')]);_0x4161b6['attributes']=_[_0x4dc5('0x47')](_0x5cb34a[_0x4dc5('0x44')],qs['fields'](_0x3fab35['query'][_0x4dc5('0x48')]));_0x4161b6[_0x4dc5('0x46')]=_0x4161b6['attributes']['length']?_0x4161b6['attributes']:_0x5cb34a[_0x4dc5('0x44')];_0x4161b6[_0x4dc5('0x4b')]=qs[_0x4dc5('0x4c')](_0x3fab35[_0x4dc5('0x45')][_0x4dc5('0x4c')]);_0x4161b6[_0x4dc5('0x4d')]=qs['filters'](_['pick'](_0x3fab35[_0x4dc5('0x45')],_0x5cb34a[_0x4dc5('0x4e')]));if(_0x3fab35[_0x4dc5('0x45')][_0x4dc5('0x50')]){_0x4161b6['where']=_['merge'](_0x4161b6[_0x4dc5('0x4d')],{'$or':_[_0x4dc5('0x41')](_0x4161b6[_0x4dc5('0x46')],function(_0x279f97){var _0x1b765c={};_0x1b765c[_0x279f97]={'$like':'%'+_0x3fab35['query'][_0x4dc5('0x50')]+'%'};return _0x1b765c;})});}_0x4161b6=_[_0x4dc5('0x51')]({},_0x4161b6,_0x3fab35[_0x4dc5('0x5b')]);return _0x5a26b8['getAgents'](_0x4161b6);}})[_0x4dc5('0x20')](function(_0x3e059e){if(_0x3e059e){_0x43ea9d=_0x3e059e[_0x4dc5('0x49')];if(!_0x3fab35[_0x4dc5('0x45')][_0x4dc5('0x6c')]('nolimit')){_0x4161b6[_0x4dc5('0x2f')]=qs[_0x4dc5('0x2f')](_0x3fab35['query']['limit']);_0x4161b6[_0x4dc5('0x31')]=qs[_0x4dc5('0x31')](_0x3fab35['query'][_0x4dc5('0x31')]);}return _0x5a26b8[_0x4dc5('0xc1')](_0x4161b6);}})[_0x4dc5('0x20')](function(_0x3f8406){if(_0x3f8406){return _0x3f8406?{'count':_0x43ea9d,'rows':_0x3f8406}:null;}})[_0x4dc5('0x20')](respondWithResult(_0xd003c7,null))[_0x4dc5('0x65')](handleError(_0xd003c7,null));};
\ No newline at end of file