Built motion from commit (unavailable).|2.5.28
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index 5a500e9..f40c61e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfd7b=['attributes','fields','length','nolimit','order','sort','pick','filter','merge','where','VIRTUAL','options','includeAll','rows','show','params','keys','include','find','create','body','FaxAccounts','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','getDispositions','findOne','Disposition','hasOwnProperty','FaxAccountId','findAll','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','addInteraction','FaxInteraction','CmContact','Contact','User','Owner','fullname','internal','Tag','Tags','color','tag','addApplications','transaction','priority','getApplications','exten','system','description','appdata','push','Answer','CDR(type)=inbound-fax','Set','ecm','gateway','faxdetect','headerinfo','maxrate','minrate','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','sequelize','bulkCreate','VoiceExtension','omit','TrunkId','ListId','findById','getMessages','FaxMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','Contacts','updatedAt','attachments','join','root','basename','CheckAfterSend','isNil','\x22%s\x22\x20<%s>','List','Send\x20Fax\x20failed','user','out','filename','Messages','Contact\x20not\x20found','spread','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','emit','userFaxAccount:save','removeAgents','isArray','userFaxAccount:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','localhost','./faxAccount.socket','register','jayson/promise','client','request','then','FaxAccount,\x20%s,\x20%s','request\x20sent','error','message','info','catch','sendStatus','status','end','json','count','offset','limit','set','apply','save','update','destroy','get','UserProfileResource','stack','name','Pause','mandatoryDispositionPause','FaxAccount','rawAttributes','fieldName','type','key','model','map','query','filters','intersection'];(function(_0x35d06e,_0x2e3503){var _0x9e9053=function(_0x1546d3){while(--_0x1546d3){_0x35d06e['push'](_0x35d06e['shift']());}};_0x9e9053(++_0x2e3503);}(_0xfd7b,0x1df));var _0xbfd7=function(_0x2bc3f4,_0x470b26){_0x2bc3f4=_0x2bc3f4-0x0;var _0x14ac53=_0xfd7b[_0x2bc3f4];return _0x14ac53;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xbfd7('0x0'));var rimraf=require(_0xbfd7('0x1'));var zipdir=require(_0xbfd7('0x2'));var jsonpatch=require(_0xbfd7('0x3'));var rp=require(_0xbfd7('0x4'));var moment=require(_0xbfd7('0x5'));var BPromise=require(_0xbfd7('0x6'));var Mustache=require(_0xbfd7('0x7'));var util=require(_0xbfd7('0x8'));var path=require(_0xbfd7('0x9'));var sox=require(_0xbfd7('0xa'));var csv=require(_0xbfd7('0xb'));var ejs=require(_0xbfd7('0xc'));var fs=require('fs');var _=require('lodash');var squel=require(_0xbfd7('0xd'));var crypto=require('crypto');var jsforce=require(_0xbfd7('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xbfd7('0xb'));var querystring=require(_0xbfd7('0xf'));var Papa=require(_0xbfd7('0x10'));var Redis=require(_0xbfd7('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xbfd7('0x12'));var as=require(_0xbfd7('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xbfd7('0x14'));var utils=require(_0xbfd7('0x15'));var config=require(_0xbfd7('0x16'));var licenseUtil=require(_0xbfd7('0x17'));var db=require(_0xbfd7('0x18'))['db'];config['redis']=_[_0xbfd7('0x19')](config['redis'],{'host':_0xbfd7('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xbfd7('0x1b'))[_0xbfd7('0x1c')](socket);var jayson=require(_0xbfd7('0x1d'));var client=jayson[_0xbfd7('0x1e')]['http']({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x37e777,_0x115a34,_0x33d900,_0x3e8754){return new BPromise(function(_0x30c721,_0x4609f2){var _0x137d50=_0x3e8754||client;return _0x137d50[_0xbfd7('0x1f')](_0x37e777,_0x33d900)[_0xbfd7('0x20')](function(_0x514248){logger['info'](_0xbfd7('0x21'),_0x115a34,_0xbfd7('0x22'));logger['debug']('FaxAccount,\x20%s,\x20%s,\x20%s',_0x115a34,_0xbfd7('0x22'),JSON['stringify'](_0x514248));if(_0x514248['error']){if(_0x514248[_0xbfd7('0x23')]['code']===0x1f4){logger[_0xbfd7('0x23')](_0xbfd7('0x21'),_0x115a34,_0x514248[_0xbfd7('0x23')][_0xbfd7('0x24')]);return _0x4609f2(_0x514248['error'][_0xbfd7('0x24')]);}logger[_0xbfd7('0x23')](_0xbfd7('0x21'),_0x115a34,_0x514248[_0xbfd7('0x23')][_0xbfd7('0x24')]);return _0x30c721(_0x514248[_0xbfd7('0x23')]['message']);}else{logger[_0xbfd7('0x25')](_0xbfd7('0x21'),_0x115a34,_0xbfd7('0x22'));_0x30c721(_0x514248['result'][_0xbfd7('0x24')]);}})[_0xbfd7('0x26')](function(_0x18dd74){logger[_0xbfd7('0x23')](_0xbfd7('0x21'),_0x115a34,_0x18dd74);_0x4609f2(_0x18dd74);});});}function respondWithStatusCode(_0x585e60,_0x2a7749){_0x2a7749=_0x2a7749||0xcc;return function(_0x6ef5aa){if(_0x6ef5aa){return _0x585e60[_0xbfd7('0x27')](_0x2a7749);}return _0x585e60[_0xbfd7('0x28')](_0x2a7749)[_0xbfd7('0x29')]();};}function respondWithResult(_0x303060,_0x378428){_0x378428=_0x378428||0xc8;return function(_0x55b2c8){if(_0x55b2c8){return _0x303060[_0xbfd7('0x28')](_0x378428)[_0xbfd7('0x2a')](_0x55b2c8);}};}function respondWithFilteredResult(_0x4d7ef4,_0x2971ea){return function(_0x33583b){if(_0x33583b){var _0x2ec4a5=_0x33583b[_0xbfd7('0x2b')],_0x14c55d=_0x2971ea[_0xbfd7('0x2c')],_0x510506=_0x2971ea['offset']+_0x2971ea[_0xbfd7('0x2d')],_0x3bb808;if(_0x510506>=_0x2ec4a5){_0x510506=_0x2ec4a5;_0x3bb808=0xc8;}else{_0x3bb808=0xce;}_0x4d7ef4['status'](_0x3bb808);return _0x4d7ef4[_0xbfd7('0x2e')]('Content-Range',_0x14c55d+'-'+_0x510506+'/'+_0x2ec4a5)[_0xbfd7('0x2a')](_0x33583b);}return null;};}function patchUpdates(_0x1804a5){return function(_0x532c5f){try{jsonpatch[_0xbfd7('0x2f')](_0x532c5f,_0x1804a5,!![]);}catch(_0xde0053){return BPromise['reject'](_0xde0053);}return _0x532c5f[_0xbfd7('0x30')]();};}function saveUpdates(_0x40fef6,_0x990abe){return function(_0x5d08fe){if(_0x5d08fe){return _0x5d08fe[_0xbfd7('0x31')](_0x40fef6)[_0xbfd7('0x20')](function(_0x267b31){return _0x267b31;});}return null;};}function removeEntity(_0x2a9361,_0x20fc00){return function(_0x3af799){if(_0x3af799){return _0x3af799[_0xbfd7('0x32')]()[_0xbfd7('0x20')](function(){var _0x418994=_0x3af799[_0xbfd7('0x33')]({'plain':!![]});var _0x26802b='FaxAccounts';return db[_0xbfd7('0x34')]['destroy']({'where':{'type':_0x26802b,'resourceId':_0x418994['id']}})['then'](function(){return _0x3af799;});})[_0xbfd7('0x20')](function(){_0x2a9361[_0xbfd7('0x28')](0xcc)[_0xbfd7('0x29')]();});}};}function handleEntityNotFound(_0x6d440c,_0xc51f8b){return function(_0x403bf5){if(!_0x403bf5){_0x6d440c[_0xbfd7('0x27')](0x194);}return _0x403bf5;};}function handleError(_0x373c4a,_0x5d4928){_0x5d4928=_0x5d4928||0x1f4;return function(_0x4b275e){logger[_0xbfd7('0x23')](_0x4b275e[_0xbfd7('0x35')]);if(_0x4b275e['name']){delete _0x4b275e[_0xbfd7('0x36')];}_0x373c4a[_0xbfd7('0x28')](_0x5d4928)['send'](_0x4b275e);};}exports['index']=function(_0x6ec28c,_0x2391b6){var _0x51fce9={'include':[{'model':db[_0xbfd7('0x37')],'as':_0xbfd7('0x38')}]},_0x1d54da={},_0xfee712={'count':0x0,'rows':[]};var _0x68f13=_['map'](db[_0xbfd7('0x39')][_0xbfd7('0x3a')],function(_0x530210){return{'name':_0x530210[_0xbfd7('0x3b')],'type':_0x530210[_0xbfd7('0x3c')][_0xbfd7('0x3d')]};});_0x1d54da[_0xbfd7('0x3e')]=_[_0xbfd7('0x3f')](_0x68f13,'name');_0x1d54da[_0xbfd7('0x40')]=_['keys'](_0x6ec28c['query']);_0x1d54da[_0xbfd7('0x41')]=_[_0xbfd7('0x42')](_0x1d54da[_0xbfd7('0x3e')],_0x1d54da[_0xbfd7('0x40')]);_0x51fce9[_0xbfd7('0x43')]=_[_0xbfd7('0x42')](_0x1d54da['model'],qs[_0xbfd7('0x44')](_0x6ec28c['query'][_0xbfd7('0x44')]));_0x51fce9[_0xbfd7('0x43')]=_0x51fce9[_0xbfd7('0x43')][_0xbfd7('0x45')]?_0x51fce9[_0xbfd7('0x43')]:_0x1d54da[_0xbfd7('0x3e')];if(!_0x6ec28c[_0xbfd7('0x40')]['hasOwnProperty'](_0xbfd7('0x46'))){_0x51fce9[_0xbfd7('0x2d')]=qs[_0xbfd7('0x2d')](_0x6ec28c[_0xbfd7('0x40')][_0xbfd7('0x2d')]);_0x51fce9[_0xbfd7('0x2c')]=qs[_0xbfd7('0x2c')](_0x6ec28c['query'][_0xbfd7('0x2c')]);}_0x51fce9[_0xbfd7('0x47')]=qs[_0xbfd7('0x48')](_0x6ec28c['query']['sort']);_0x51fce9['where']=qs[_0xbfd7('0x41')](_[_0xbfd7('0x49')](_0x6ec28c[_0xbfd7('0x40')],_0x1d54da[_0xbfd7('0x41')]),_0x68f13);if(_0x6ec28c['query'][_0xbfd7('0x4a')]){_0x51fce9['where']=_[_0xbfd7('0x4b')](_0x51fce9[_0xbfd7('0x4c')],{'$or':_['map'](_0x68f13,function(_0x4137aa){if(_0x4137aa['type']!==_0xbfd7('0x4d')){var _0x2e3e1c={};_0x2e3e1c[_0x4137aa[_0xbfd7('0x36')]]={'$like':'%'+_0x6ec28c['query']['filter']+'%'};return _0x2e3e1c;}})});}_0x51fce9=_[_0xbfd7('0x4b')]({},_0x51fce9,_0x6ec28c[_0xbfd7('0x4e')]);var _0x4d700e={'where':_0x51fce9['where']};return db[_0xbfd7('0x39')][_0xbfd7('0x2b')](_0x4d700e)[_0xbfd7('0x20')](function(_0x9279a1){_0xfee712[_0xbfd7('0x2b')]=_0x9279a1;if(_0x6ec28c[_0xbfd7('0x40')][_0xbfd7('0x4f')]){_0x51fce9['include']=[{'all':!![]}];}return db['FaxAccount']['findAll'](_0x51fce9);})[_0xbfd7('0x20')](function(_0x20bd15){_0xfee712[_0xbfd7('0x50')]=_0x20bd15;return _0xfee712;})['then'](respondWithFilteredResult(_0x2391b6,_0x51fce9))[_0xbfd7('0x26')](handleError(_0x2391b6,null));};exports[_0xbfd7('0x51')]=function(_0x4ae9f9,_0x4a7a72){var _0xc89535={'raw':![],'where':{'id':_0x4ae9f9[_0xbfd7('0x52')]['id']},'include':[{'model':db['Pause'],'as':_0xbfd7('0x38')}]},_0x7443a1={};_0x7443a1[_0xbfd7('0x3e')]=_[_0xbfd7('0x53')](db['FaxAccount'][_0xbfd7('0x3a')]);_0x7443a1[_0xbfd7('0x40')]=_[_0xbfd7('0x53')](_0x4ae9f9[_0xbfd7('0x40')]);_0x7443a1['filters']=_[_0xbfd7('0x42')](_0x7443a1[_0xbfd7('0x3e')],_0x7443a1[_0xbfd7('0x40')]);_0xc89535['attributes']=_[_0xbfd7('0x42')](_0x7443a1['model'],qs[_0xbfd7('0x44')](_0x4ae9f9[_0xbfd7('0x40')][_0xbfd7('0x44')]));_0xc89535[_0xbfd7('0x43')]=_0xc89535['attributes'][_0xbfd7('0x45')]?_0xc89535[_0xbfd7('0x43')]:_0x7443a1[_0xbfd7('0x3e')];if(_0x4ae9f9[_0xbfd7('0x40')][_0xbfd7('0x4f')]){_0xc89535[_0xbfd7('0x54')]=[{'all':!![]}];}_0xc89535=_[_0xbfd7('0x4b')]({},_0xc89535,_0x4ae9f9[_0xbfd7('0x4e')]);return db[_0xbfd7('0x39')][_0xbfd7('0x55')](_0xc89535)[_0xbfd7('0x20')](handleEntityNotFound(_0x4a7a72,null))[_0xbfd7('0x20')](respondWithResult(_0x4a7a72,null))[_0xbfd7('0x26')](handleError(_0x4a7a72,null));};exports[_0xbfd7('0x56')]=function(_0x5ad6c8,_0x5a49e7){return db[_0xbfd7('0x39')][_0xbfd7('0x56')](_0x5ad6c8[_0xbfd7('0x57')],{})[_0xbfd7('0x20')](function(_0x3142ba){var _0x3245d8=_0x5ad6c8['user'][_0xbfd7('0x33')]({'plain':!![]});if(!_0x3245d8)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3245d8['role']==='user'){var _0x2ce454=_0x3142ba[_0xbfd7('0x33')]({'plain':!![]});var _0x5e47c2=_0xbfd7('0x58');return db[_0xbfd7('0x59')][_0xbfd7('0x55')]({'where':{'name':_0x5e47c2,'userProfileId':_0x3245d8[_0xbfd7('0x5a')]},'raw':!![]})[_0xbfd7('0x20')](function(_0x450989){if(_0x450989&&_0x450989[_0xbfd7('0x5b')]===0x0){return db[_0xbfd7('0x34')][_0xbfd7('0x56')]({'name':_0x2ce454['name'],'resourceId':_0x2ce454['id'],'type':_0x450989[_0xbfd7('0x36')],'sectionId':_0x450989['id']},{})[_0xbfd7('0x20')](function(){return _0x3142ba;});}else{return _0x3142ba;}})[_0xbfd7('0x26')](function(_0x531f97){logger['error'](_0xbfd7('0x5c'),_0x531f97);throw _0x531f97;});}return _0x3142ba;})[_0xbfd7('0x20')](respondWithResult(_0x5a49e7,0xc9))[_0xbfd7('0x26')](handleError(_0x5a49e7,null));};exports[_0xbfd7('0x31')]=function(_0x508a8a,_0x41d54c){if(_0x508a8a[_0xbfd7('0x57')]['id']){delete _0x508a8a[_0xbfd7('0x57')]['id'];}return db[_0xbfd7('0x39')][_0xbfd7('0x55')]({'where':{'id':_0x508a8a[_0xbfd7('0x52')]['id']},'include':[{'model':db[_0xbfd7('0x37')],'as':_0xbfd7('0x38')}]})[_0xbfd7('0x20')](handleEntityNotFound(_0x41d54c,null))[_0xbfd7('0x20')](saveUpdates(_0x508a8a[_0xbfd7('0x57')],null))[_0xbfd7('0x20')](respondWithResult(_0x41d54c,null))[_0xbfd7('0x26')](handleError(_0x41d54c,null));};exports['destroy']=function(_0x383241,_0xed99c4){return db[_0xbfd7('0x39')]['find']({'where':{'id':_0x383241[_0xbfd7('0x52')]['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0xed99c4,null))[_0xbfd7('0x20')](removeEntity(_0xed99c4,null))[_0xbfd7('0x26')](handleError(_0xed99c4,null));};exports[_0xbfd7('0x5d')]=function(_0x569612,_0x3196a7){return db[_0xbfd7('0x39')][_0xbfd7('0x5d')]()[_0xbfd7('0x20')](respondWithResult(_0x3196a7,null))[_0xbfd7('0x26')](handleError(_0x3196a7,null));};exports[_0xbfd7('0x5e')]=function(_0x35b346,_0x476731,_0x460bc7){if(_0x35b346[_0xbfd7('0x57')]['id']){delete _0x35b346[_0xbfd7('0x57')]['id'];}return db[_0xbfd7('0x39')]['find']({'where':{'id':_0x35b346['params']['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x476731,null))[_0xbfd7('0x20')](function(_0x13ce36){if(_0x13ce36){_0x35b346[_0xbfd7('0x57')]['FaxAccountId']=_0x13ce36['id'];return db['Disposition'][_0xbfd7('0x56')](_0x35b346[_0xbfd7('0x57')]);}})['then'](respondWithResult(_0x476731,null))[_0xbfd7('0x26')](handleError(_0x476731,null));};exports[_0xbfd7('0x5f')]=function(_0x4c1670,_0x3ca88c,_0x29c568){var _0x11cf3b={'raw':![],'where':{}};var _0x5ad203={};var _0x93f60={'count':0x0,'rows':[]};return db['FaxAccount'][_0xbfd7('0x60')]({'where':{'id':_0x4c1670[_0xbfd7('0x52')]['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x3ca88c,null))[_0xbfd7('0x20')](function(_0x320cbf){if(_0x320cbf){_0x5ad203[_0xbfd7('0x3e')]=_[_0xbfd7('0x53')](db[_0xbfd7('0x61')][_0xbfd7('0x3a')]);_0x5ad203['query']=_[_0xbfd7('0x53')](_0x4c1670[_0xbfd7('0x40')]);_0x5ad203[_0xbfd7('0x41')]=_[_0xbfd7('0x42')](_0x5ad203[_0xbfd7('0x3e')],_0x5ad203[_0xbfd7('0x40')]);_0x11cf3b[_0xbfd7('0x43')]=_[_0xbfd7('0x42')](_0x5ad203['model'],qs[_0xbfd7('0x44')](_0x4c1670[_0xbfd7('0x40')]['fields']));_0x11cf3b['attributes']=_0x11cf3b[_0xbfd7('0x43')][_0xbfd7('0x45')]?_0x11cf3b[_0xbfd7('0x43')]:_0x5ad203[_0xbfd7('0x3e')];if(!_0x4c1670[_0xbfd7('0x40')][_0xbfd7('0x62')](_0xbfd7('0x46'))){_0x11cf3b[_0xbfd7('0x2d')]=qs['limit'](_0x4c1670[_0xbfd7('0x40')][_0xbfd7('0x2d')]);_0x11cf3b[_0xbfd7('0x2c')]=qs[_0xbfd7('0x2c')](_0x4c1670[_0xbfd7('0x40')]['offset']);}_0x11cf3b[_0xbfd7('0x47')]=qs['sort'](_0x4c1670['query'][_0xbfd7('0x48')]);_0x11cf3b[_0xbfd7('0x4c')]=qs[_0xbfd7('0x41')](_[_0xbfd7('0x49')](_0x4c1670['query'],_0x5ad203[_0xbfd7('0x41')]));_0x11cf3b[_0xbfd7('0x4c')][_0xbfd7('0x63')]=_0x320cbf['id'];if(_0x4c1670[_0xbfd7('0x40')][_0xbfd7('0x4a')]){_0x11cf3b[_0xbfd7('0x4c')]=_[_0xbfd7('0x4b')](_0x11cf3b[_0xbfd7('0x4c')],{'$or':_[_0xbfd7('0x3f')](_0x11cf3b['attributes'],function(_0x4b3891){var _0x2635a6={};_0x2635a6[_0x4b3891]={'$like':'%'+_0x4c1670[_0xbfd7('0x40')]['filter']+'%'};return _0x2635a6;})});}_0x11cf3b=_[_0xbfd7('0x4b')]({},_0x11cf3b,_0x4c1670[_0xbfd7('0x4e')]);return db[_0xbfd7('0x61')][_0xbfd7('0x2b')]({'where':_0x11cf3b[_0xbfd7('0x4c')]})[_0xbfd7('0x20')](function(_0x11b905){_0x93f60[_0xbfd7('0x2b')]=_0x11b905;if(_0x4c1670[_0xbfd7('0x40')][_0xbfd7('0x4f')]){_0x11cf3b[_0xbfd7('0x54')]=[{'all':!![]}];}return db[_0xbfd7('0x61')][_0xbfd7('0x64')](_0x11cf3b);})['then'](function(_0x39ee78){_0x93f60[_0xbfd7('0x50')]=_0x39ee78;return _0x93f60;});}})[_0xbfd7('0x20')](respondWithFilteredResult(_0x3ca88c,_0x11cf3b))[_0xbfd7('0x26')](handleError(_0x3ca88c,null));};exports[_0xbfd7('0x65')]=function(_0x2520e2,_0x33fd18,_0x57233f){return db[_0xbfd7('0x39')][_0xbfd7('0x55')]({'where':{'id':_0x2520e2['params']['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x33fd18,null))[_0xbfd7('0x20')](function(_0x2d3e38){if(_0x2d3e38){return _0x2d3e38['removeDispositions'](_0x2520e2[_0xbfd7('0x40')][_0xbfd7('0x66')]);}})[_0xbfd7('0x20')](respondWithStatusCode(_0x33fd18,null))['catch'](handleError(_0x33fd18,null));};exports[_0xbfd7('0x67')]=function(_0x378dd2,_0x23e9cb,_0x18f6b6){if(_0x378dd2[_0xbfd7('0x57')]['id']){delete _0x378dd2[_0xbfd7('0x57')]['id'];}return db['FaxAccount'][_0xbfd7('0x55')]({'where':{'id':_0x378dd2['params']['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x23e9cb,null))[_0xbfd7('0x20')](function(_0x504f27){if(_0x504f27){_0x378dd2[_0xbfd7('0x57')][_0xbfd7('0x63')]=_0x504f27['id'];return db[_0xbfd7('0x68')][_0xbfd7('0x56')](_0x378dd2['body']);}})[_0xbfd7('0x20')](respondWithResult(_0x23e9cb,null))[_0xbfd7('0x26')](handleError(_0x23e9cb,null));};exports[_0xbfd7('0x69')]=function(_0x745d6f,_0x4d6980,_0xbd1ae7){var _0x58ee6e={'raw':![],'where':{}};var _0x90bcc5={};var _0x4df4f7={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x745d6f[_0xbfd7('0x52')]['id']}})['then'](handleEntityNotFound(_0x4d6980,null))[_0xbfd7('0x20')](function(_0x36441e){if(_0x36441e){_0x90bcc5[_0xbfd7('0x3e')]=_[_0xbfd7('0x53')](db[_0xbfd7('0x68')][_0xbfd7('0x3a')]);_0x90bcc5[_0xbfd7('0x40')]=_[_0xbfd7('0x53')](_0x745d6f[_0xbfd7('0x40')]);_0x90bcc5[_0xbfd7('0x41')]=_[_0xbfd7('0x42')](_0x90bcc5[_0xbfd7('0x3e')],_0x90bcc5[_0xbfd7('0x40')]);_0x58ee6e['attributes']=_['intersection'](_0x90bcc5[_0xbfd7('0x3e')],qs['fields'](_0x745d6f['query'][_0xbfd7('0x44')]));_0x58ee6e[_0xbfd7('0x43')]=_0x58ee6e['attributes'][_0xbfd7('0x45')]?_0x58ee6e[_0xbfd7('0x43')]:_0x90bcc5[_0xbfd7('0x3e')];if(!_0x745d6f[_0xbfd7('0x40')][_0xbfd7('0x62')](_0xbfd7('0x46'))){_0x58ee6e['limit']=qs['limit'](_0x745d6f[_0xbfd7('0x40')]['limit']);_0x58ee6e[_0xbfd7('0x2c')]=qs[_0xbfd7('0x2c')](_0x745d6f[_0xbfd7('0x40')]['offset']);}_0x58ee6e[_0xbfd7('0x47')]=qs[_0xbfd7('0x48')](_0x745d6f[_0xbfd7('0x40')]['sort']);_0x58ee6e[_0xbfd7('0x4c')]=qs['filters'](_[_0xbfd7('0x49')](_0x745d6f[_0xbfd7('0x40')],_0x90bcc5[_0xbfd7('0x41')]));_0x58ee6e[_0xbfd7('0x4c')][_0xbfd7('0x63')]=_0x36441e['id'];if(_0x745d6f['query'][_0xbfd7('0x4a')]){_0x58ee6e[_0xbfd7('0x4c')]=_['merge'](_0x58ee6e[_0xbfd7('0x4c')],{'$or':_[_0xbfd7('0x3f')](_0x58ee6e['attributes'],function(_0x8492fc){var _0x5d8a43={};_0x5d8a43[_0x8492fc]={'$like':'%'+_0x745d6f['query'][_0xbfd7('0x4a')]+'%'};return _0x5d8a43;})});}_0x58ee6e=_['merge']({},_0x58ee6e,_0x745d6f['options']);return db[_0xbfd7('0x68')][_0xbfd7('0x2b')]({'where':_0x58ee6e[_0xbfd7('0x4c')]})[_0xbfd7('0x20')](function(_0x37dfce){_0x4df4f7[_0xbfd7('0x2b')]=_0x37dfce;if(_0x745d6f[_0xbfd7('0x40')][_0xbfd7('0x4f')]){_0x58ee6e[_0xbfd7('0x54')]=[{'all':!![]}];}return db['CannedAnswer'][_0xbfd7('0x64')](_0x58ee6e);})['then'](function(_0x50f8bf){_0x4df4f7[_0xbfd7('0x50')]=_0x50f8bf;return _0x4df4f7;});}})[_0xbfd7('0x20')](respondWithFilteredResult(_0x4d6980,_0x58ee6e))['catch'](handleError(_0x4d6980,null));};exports[_0xbfd7('0x6a')]=function(_0x589a71,_0x5f1255,_0x5daba9){return db[_0xbfd7('0x39')][_0xbfd7('0x55')]({'where':{'id':_0x589a71['params']['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x5f1255,null))[_0xbfd7('0x20')](function(_0x1bf04d){if(_0x1bf04d){return _0x1bf04d[_0xbfd7('0x6a')](_0x589a71[_0xbfd7('0x40')]['ids']);}})[_0xbfd7('0x20')](respondWithStatusCode(_0x5f1255,null))['catch'](handleError(_0x5f1255,null));};exports[_0xbfd7('0x6b')]=function(_0x41147f,_0x1cbe56,_0x32c787){return db[_0xbfd7('0x6c')][_0xbfd7('0x55')]({'where':{'id':_0x41147f['params']['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x1cbe56,null))[_0xbfd7('0x20')](function(_0x6f4618){if(_0x6f4618){return _0x6f4618[_0xbfd7('0x6b')](_0x41147f[_0xbfd7('0x57')][_0xbfd7('0x66')],_['omit'](_0x41147f[_0xbfd7('0x57')],['ids','id'])||{});}})[_0xbfd7('0x20')](respondWithResult(_0x1cbe56,null))[_0xbfd7('0x26')](handleError(_0x1cbe56,null));};exports['getInteractions']=function(_0x47f8ff,_0x4017bf,_0xb2f119){var _0xd58d3b={'raw':![],'where':{}};var _0x42bd52={};var _0x7e12d5={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x47f8ff[_0xbfd7('0x52')]['id']}})['then'](handleEntityNotFound(_0x4017bf,null))[_0xbfd7('0x20')](function(_0x4a139a){if(_0x4a139a){_0x42bd52['model']=_['keys'](db['FaxInteraction'][_0xbfd7('0x3a')]);_0x42bd52[_0xbfd7('0x40')]=_[_0xbfd7('0x53')](_0x47f8ff['query']);_0x42bd52[_0xbfd7('0x41')]=_[_0xbfd7('0x42')](_0x42bd52[_0xbfd7('0x3e')],_0x42bd52['query']);_0xd58d3b[_0xbfd7('0x43')]=_['intersection'](_0x42bd52['model'],qs[_0xbfd7('0x44')](_0x47f8ff[_0xbfd7('0x40')][_0xbfd7('0x44')]));_0xd58d3b['attributes']=_0xd58d3b[_0xbfd7('0x43')][_0xbfd7('0x45')]?_0xd58d3b[_0xbfd7('0x43')]:_0x42bd52['model'];if(!_0x47f8ff[_0xbfd7('0x40')][_0xbfd7('0x62')](_0xbfd7('0x46'))){_0xd58d3b[_0xbfd7('0x2d')]=qs[_0xbfd7('0x2d')](_0x47f8ff[_0xbfd7('0x40')]['limit']);_0xd58d3b[_0xbfd7('0x2c')]=qs['offset'](_0x47f8ff[_0xbfd7('0x40')][_0xbfd7('0x2c')]);}_0xd58d3b[_0xbfd7('0x47')]=qs['sort'](_0x47f8ff[_0xbfd7('0x40')]['sort']);_0xd58d3b['where']=qs[_0xbfd7('0x41')](_[_0xbfd7('0x49')](_0x47f8ff[_0xbfd7('0x40')],_0x42bd52[_0xbfd7('0x41')]));_0xd58d3b[_0xbfd7('0x4c')][_0xbfd7('0x63')]=_0x4a139a['id'];if(_0x47f8ff['query'][_0xbfd7('0x4a')]){_0xd58d3b[_0xbfd7('0x4c')]=_[_0xbfd7('0x4b')](_0xd58d3b[_0xbfd7('0x4c')],{'$or':_['map'](_0xd58d3b[_0xbfd7('0x43')],function(_0x20fdeb){var _0x3ff80f={};_0x3ff80f[_0x20fdeb]={'$like':'%'+_0x47f8ff[_0xbfd7('0x40')]['filter']+'%'};return _0x3ff80f;})});}_0xd58d3b=_['merge']({},_0xd58d3b,_0x47f8ff[_0xbfd7('0x4e')]);return db[_0xbfd7('0x6c')][_0xbfd7('0x2b')]({'where':_0xd58d3b[_0xbfd7('0x4c')]})[_0xbfd7('0x20')](function(_0xe329c0){_0x7e12d5[_0xbfd7('0x2b')]=_0xe329c0;if(_0x47f8ff[_0xbfd7('0x40')][_0xbfd7('0x4f')]){_0xd58d3b[_0xbfd7('0x54')]=[{'model':db[_0xbfd7('0x6d')],'as':_0xbfd7('0x6e'),'required':![]},{'model':db[_0xbfd7('0x6f')],'as':_0xbfd7('0x70'),'attributes':['name',_0xbfd7('0x71'),_0xbfd7('0x72')],'required':![]},{'model':db[_0xbfd7('0x73')],'as':_0xbfd7('0x74'),'attributes':['id',_0xbfd7('0x36'),_0xbfd7('0x75')],'where':_0x47f8ff[_0xbfd7('0x40')][_0xbfd7('0x76')]?{'id':_0x47f8ff['query']['tag']}:undefined,'required':_0x47f8ff[_0xbfd7('0x40')]['tag']?!![]:![]}];}return db[_0xbfd7('0x6c')][_0xbfd7('0x64')](_0xd58d3b);})[_0xbfd7('0x20')](function(_0x355e9b){_0x7e12d5[_0xbfd7('0x50')]=_0x355e9b;return _0x7e12d5;});}})[_0xbfd7('0x20')](respondWithFilteredResult(_0x4017bf,_0xd58d3b))[_0xbfd7('0x26')](handleError(_0x4017bf,null));};exports[_0xbfd7('0x77')]=function(_0x5412f2,_0x598b04,_0x4175f1){return db[_0xbfd7('0x39')]['findOne']({'where':{'id':_0x5412f2[_0xbfd7('0x52')]['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x598b04,null))[_0xbfd7('0x20')](function(_0x5c96af){if(_0x5c96af){return db['sequelize'][_0xbfd7('0x78')](function(_0x1a2d85){return db['FaxApplication']['destroy']({'where':{'FaxAccountId':_0x5412f2[_0xbfd7('0x52')]['id']},'transaction':_0x1a2d85})['then'](function(_0x1498c8){var _0x33f669=_[_0xbfd7('0x3f')](_0x5412f2['body'],function(_0x10f512){_0x10f512[_0xbfd7('0x63')]=_0x5412f2[_0xbfd7('0x52')]['id'];return _0x10f512;});return db['FaxApplication']['bulkCreate'](_0x33f669,{'transaction':_0x1a2d85});});})['then'](function(){return db['FaxApplication']['findAndCountAll']({'where':{'FaxAccountId':_0x5412f2[_0xbfd7('0x52')]['id']},'order':_0xbfd7('0x79')});});}})[_0xbfd7('0x20')](respondWithResult(_0x598b04,null))[_0xbfd7('0x26')](handleError(_0x598b04,null));};exports['getApplications']=function(_0x1e5813,_0x1f362a,_0x20d691){var _0x4e31be={};var _0x549644={};var _0x2830fe;var _0x52346d;return db[_0xbfd7('0x39')]['findOne']({'where':{'id':_0x1e5813[_0xbfd7('0x52')]['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x1f362a,null))[_0xbfd7('0x20')](function(_0x51d7df){if(_0x51d7df){_0x2830fe=_0x51d7df;_0x549644[_0xbfd7('0x3e')]=_[_0xbfd7('0x53')](db['FaxApplication'][_0xbfd7('0x3a')]);_0x549644['query']=_['keys'](_0x1e5813['query']);_0x549644[_0xbfd7('0x41')]=_[_0xbfd7('0x42')](_0x549644[_0xbfd7('0x3e')],_0x549644[_0xbfd7('0x40')]);_0x4e31be[_0xbfd7('0x43')]=_[_0xbfd7('0x42')](_0x549644[_0xbfd7('0x3e')],qs[_0xbfd7('0x44')](_0x1e5813[_0xbfd7('0x40')]['fields']));_0x4e31be[_0xbfd7('0x43')]=_0x4e31be['attributes'][_0xbfd7('0x45')]?_0x4e31be[_0xbfd7('0x43')]:_0x549644[_0xbfd7('0x3e')];_0x4e31be['order']=qs[_0xbfd7('0x48')](_0x1e5813[_0xbfd7('0x40')][_0xbfd7('0x48')]);_0x4e31be[_0xbfd7('0x4c')]=qs[_0xbfd7('0x41')](_['pick'](_0x1e5813[_0xbfd7('0x40')],_0x549644[_0xbfd7('0x41')]));if(_0x1e5813[_0xbfd7('0x40')]['filter']){_0x4e31be[_0xbfd7('0x4c')]=_[_0xbfd7('0x4b')](_0x4e31be[_0xbfd7('0x4c')],{'$or':_[_0xbfd7('0x3f')](_0x4e31be[_0xbfd7('0x43')],function(_0x43bed8){var _0x13f40d={};_0x13f40d[_0x43bed8]={'$like':'%'+_0x1e5813[_0xbfd7('0x40')][_0xbfd7('0x4a')]+'%'};return _0x13f40d;})});}_0x4e31be=_[_0xbfd7('0x4b')]({},_0x4e31be,_0x1e5813[_0xbfd7('0x4e')]);return _0x2830fe[_0xbfd7('0x7a')](_0x4e31be);}})[_0xbfd7('0x20')](function(_0x492a1e){if(_0x492a1e){_0x52346d=_0x492a1e[_0xbfd7('0x45')];if(!_0x1e5813[_0xbfd7('0x40')][_0xbfd7('0x62')](_0xbfd7('0x46'))){_0x4e31be[_0xbfd7('0x2d')]=qs[_0xbfd7('0x2d')](_0x1e5813[_0xbfd7('0x40')][_0xbfd7('0x2d')]);_0x4e31be['offset']=qs['offset'](_0x1e5813[_0xbfd7('0x40')][_0xbfd7('0x2c')]);}return _0x2830fe[_0xbfd7('0x7a')](_0x4e31be);}})['then'](function(_0x49693e){if(_0x49693e){return _0x49693e?{'count':_0x52346d,'rows':_0x49693e}:null;}})['then'](respondWithResult(_0x1f362a,null))[_0xbfd7('0x26')](handleError(_0x1f362a,null));};function Extension(_0x54e9a0,_0x1e845e,_0x4aaf4a,_0x4df5b3){this['context']='from-voip-provider';this[_0xbfd7('0x7b')]=_0x54e9a0['localstationid'];this['app']=_0x4df5b3;this['type']=_0xbfd7('0x7c');this[_0xbfd7('0x7d')]='Fax\x20Extension';this['FaxAccountId']=_0x54e9a0['id'];this['priority']=_0x1e845e;this[_0xbfd7('0x7e')]=_0x4aaf4a;}function createExtensionsReciveFax(_0x10b72c){var _0x5d2d6f=0x1;var _0x343953=[];_0x343953[_0xbfd7('0x7f')](new Extension(_0x10b72c,_0x5d2d6f,'',_0xbfd7('0x80')));_0x5d2d6f+=0x1;_0x343953[_0xbfd7('0x7f')](new Extension(_0x10b72c,_0x5d2d6f,_0xbfd7('0x81'),_0xbfd7('0x82')));_0x5d2d6f+=0x1;for(var _0x331ff8 in _0x10b72c){if(_0x10b72c[_0xbfd7('0x62')](_0x331ff8)&&(_0x331ff8===_0xbfd7('0x83')||_0x331ff8==='localstationid'||_0x331ff8===_0xbfd7('0x84')||_0x331ff8===_0xbfd7('0x85')||_0x331ff8===_0xbfd7('0x86')||_0x331ff8===_0xbfd7('0x87')||_0x331ff8===_0xbfd7('0x88')||_0x331ff8==='modem'||_0x331ff8==='t38timeout')){_0x343953[_0xbfd7('0x7f')](new Extension(_0x10b72c,_0x5d2d6f,_0xbfd7('0x89')+_0x331ff8+')='+_0x10b72c[_0x331ff8],_0xbfd7('0x82')));_0x5d2d6f+=0x1;}}_0x343953['push'](new Extension(_0x10b72c,_0x5d2d6f,'6','Wait'));_0x5d2d6f+=0x1;_0x343953[_0xbfd7('0x7f')](new Extension(_0x10b72c,_0x5d2d6f,_0xbfd7('0x8a'),_0xbfd7('0x8b')));_0x5d2d6f=0x0;return _0x343953;}exports[_0xbfd7('0x8c')]=function(_0x4b748b,_0x5be52a,_0x5ea323){var _0x1bceb5;return db[_0xbfd7('0x8d')]['transaction'](function(_0x499dbd){return db['FaxAccount'][_0xbfd7('0x56')](_0x4b748b[_0xbfd7('0x57')],{'transaction':_0x499dbd})[_0xbfd7('0x20')](function(_0x29426c){_0x1bceb5=_0x29426c[_0xbfd7('0x33')]({'plain':!![]});return db['VoiceExtension'][_0xbfd7('0x8e')](createExtensionsReciveFax(_0x1bceb5),{'transaction':_0x499dbd});});})[_0xbfd7('0x20')](function(){return _0x1bceb5;})[_0xbfd7('0x20')](respondWithResult(_0x5be52a,null))['catch'](handleError(_0x5be52a,null));};exports['updateAccountApplications']=function(_0x38eabf,_0x7b5edf,_0x45fc5b){var _0x4949b1;return db['sequelize'][_0xbfd7('0x78')](function(_0x32752b){return db[_0xbfd7('0x39')][_0xbfd7('0x31')](_0x38eabf[_0xbfd7('0x57')],{'where':{'id':_0x38eabf[_0xbfd7('0x57')]['id']},'transaction':_0x32752b})['then'](function(_0x1460b2){return db[_0xbfd7('0x8f')][_0xbfd7('0x32')]({'where':{'FaxAccountId':_0x38eabf[_0xbfd7('0x57')]['id']},'transaction':_0x32752b})[_0xbfd7('0x20')](function(_0x31a152){return db['VoiceExtension']['bulkCreate'](createExtensionsReciveFax(_[_0xbfd7('0x90')](_0x38eabf['body'],['tech',_0xbfd7('0x3d'),'createdAt','updatedAt',_0xbfd7('0x91'),_0xbfd7('0x92')])),{'transaction':_0x32752b});});});})[_0xbfd7('0x20')](function(){return db['FaxAccount'][_0xbfd7('0x93')](_0x38eabf[_0xbfd7('0x57')]['id']);})['then'](respondWithResult(_0x7b5edf,null))[_0xbfd7('0x26')](handleError(_0x7b5edf,null));};exports[_0xbfd7('0x94')]=function(_0x5ac894,_0x23cf5b,_0x49028f){var _0x53d6c6={'raw':!![],'where':{}};var _0x773aa0={};var _0x58c252={'count':0x0,'rows':[]};return db['FaxAccount'][_0xbfd7('0x60')]({'where':{'id':_0x5ac894[_0xbfd7('0x52')]['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x23cf5b,null))[_0xbfd7('0x20')](function(_0x24a2c2){if(_0x24a2c2){_0x773aa0[_0xbfd7('0x3e')]=_['keys'](db[_0xbfd7('0x95')][_0xbfd7('0x3a')]);_0x773aa0[_0xbfd7('0x40')]=_[_0xbfd7('0x53')](_0x5ac894[_0xbfd7('0x40')]);_0x773aa0['filters']=_['intersection'](_0x773aa0['model'],_0x773aa0['query']);_0x53d6c6[_0xbfd7('0x43')]=_[_0xbfd7('0x42')](_0x773aa0[_0xbfd7('0x3e')],qs[_0xbfd7('0x44')](_0x5ac894[_0xbfd7('0x40')][_0xbfd7('0x44')]));_0x53d6c6[_0xbfd7('0x43')]=_0x53d6c6[_0xbfd7('0x43')]['length']?_0x53d6c6['attributes']:_0x773aa0[_0xbfd7('0x3e')];if(!_0x5ac894[_0xbfd7('0x40')][_0xbfd7('0x62')](_0xbfd7('0x46'))){_0x53d6c6['limit']=qs['limit'](_0x5ac894['query'][_0xbfd7('0x2d')]);_0x53d6c6[_0xbfd7('0x2c')]=qs[_0xbfd7('0x2c')](_0x5ac894[_0xbfd7('0x40')]['offset']);}_0x53d6c6['order']=qs[_0xbfd7('0x48')](_0x5ac894[_0xbfd7('0x40')][_0xbfd7('0x48')]);_0x53d6c6[_0xbfd7('0x4c')]=qs['filters'](_[_0xbfd7('0x49')](_0x5ac894[_0xbfd7('0x40')],_0x773aa0[_0xbfd7('0x41')]));_0x53d6c6[_0xbfd7('0x4c')][_0xbfd7('0x63')]=_0x24a2c2['id'];if(_0x5ac894[_0xbfd7('0x40')][_0xbfd7('0x4a')]){_0x53d6c6['where']=_[_0xbfd7('0x4b')](_0x53d6c6[_0xbfd7('0x4c')],{'$or':_['map'](_0x53d6c6[_0xbfd7('0x43')],function(_0x1d3f43){var _0x24cf8a={};_0x24cf8a[_0x1d3f43]={'$like':'%'+_0x5ac894[_0xbfd7('0x40')][_0xbfd7('0x4a')]+'%'};return _0x24cf8a;})});}if(_0x5ac894['query'][_0xbfd7('0x96')]){var _0x3d6cc8=_0x5ac894['query'][_0xbfd7('0x96')][_0xbfd7('0x97')](',');var _0x5a6772={};_0x5a6772[_0x3d6cc8[0x0]]={'$gte':moment(_0x3d6cc8[0x1])[_0xbfd7('0x98')](_0xbfd7('0x99'))};_0x53d6c6[_0xbfd7('0x4c')]=_[_0xbfd7('0x4b')](_0x53d6c6['where'],_0x5a6772);}_0x53d6c6=_[_0xbfd7('0x4b')]({},_0x53d6c6,_0x5ac894[_0xbfd7('0x4e')]);return db['FaxMessage']['count']({'where':_0x53d6c6[_0xbfd7('0x4c')]})[_0xbfd7('0x20')](function(_0x2fe887){_0x58c252[_0xbfd7('0x2b')]=_0x2fe887;if(_0x5ac894[_0xbfd7('0x40')]['includeAll']){_0x53d6c6[_0xbfd7('0x54')]=[{'all':!![]}];}return db['FaxMessage'][_0xbfd7('0x64')](_0x53d6c6);})['then'](function(_0x47faa5){_0x58c252['rows']=_0x47faa5;return _0x58c252;});}})[_0xbfd7('0x20')](respondWithFilteredResult(_0x23cf5b,_0x53d6c6))[_0xbfd7('0x26')](handleError(_0x23cf5b,null));};exports['send']=function(_0xfb95f7,_0x432440,_0x37fdb7){var _0x3b61b6,_0xc577fb={},_0x9bc271;if(_0xfb95f7[_0xbfd7('0x57')]['to']){_0x9bc271=_0xfb95f7[_0xbfd7('0x57')]['to'][0x0];}return db[_0xbfd7('0x39')][_0xbfd7('0x55')]({'where':{'id':_0xfb95f7['params']['id']},'include':[{'model':db[_0xbfd7('0x9a')],'as':'List','include':[{'model':db['CmContact'],'as':_0xbfd7('0x9b'),'where':{'fax':_0x9bc271},'limit':0x1,'order':[[_0xbfd7('0x9c'),'DESC']]}]}]})[_0xbfd7('0x20')](handleEntityNotFound(_0x432440,null))[_0xbfd7('0x20')](function(_0x40715c){_0x3b61b6=_0x40715c;if(_0xfb95f7[_0xbfd7('0x57')]['attachments']&&_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][_0xbfd7('0x45')]){for(var _0x12e743=0x0;_0x12e743<_0xfb95f7[_0xbfd7('0x57')]['attachments'][_0xbfd7('0x45')];_0x12e743+=0x1){_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][_0x12e743]={'filename':_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][_0x12e743][_0xbfd7('0x36')],'id':_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][_0x12e743]['id'],'path':path[_0xbfd7('0x9e')](config[_0xbfd7('0x9f')],'server/files/attachments',_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][_0x12e743][_0xbfd7('0xa0')])};}}return respondWithRpcPromise(_0xbfd7('0xa1'),_0xbfd7('0xa1'),{'FaxAccountId':_[_0xbfd7('0xa2')](_0xfb95f7[_0xbfd7('0x52')]['id'])?undefined:_0xfb95f7['params']['id'],'path':_['isNil'](_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][0x0]['path'])?undefined:_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][0x0][_0xbfd7('0x9')],'fax':_[_0xbfd7('0xa2')](_0xfb95f7[_0xbfd7('0x57')]['to'][0x0])?undefined:_0xfb95f7[_0xbfd7('0x57')]['to'][0x0]},client9002);})[_0xbfd7('0x20')](function(){if(_0x3b61b6){if(_[_0xbfd7('0xa2')](_0xfb95f7[_0xbfd7('0x57')]['from'])){_0xfb95f7[_0xbfd7('0x57')]['from']=util[_0xbfd7('0x98')](_0xbfd7('0xa3'),_0x3b61b6['name'],_0x3b61b6['fax']);}if(_0x3b61b6[_0xbfd7('0xa4')]){if(_0x3b61b6['List'][_0xbfd7('0x9b')][_0xbfd7('0x45')]){return _0x3b61b6[_0xbfd7('0xa4')]['Contacts'][0x0];}else{return db[_0xbfd7('0x6d')]['create'](_[_0xbfd7('0x19')](_0xfb95f7[_0xbfd7('0x57')],{'firstName':_0xfb95f7[_0xbfd7('0x57')]['to'][0x0],'phone':_0xfb95f7['body']['to'][0x0],'fax':_0xfb95f7[_0xbfd7('0x57')]['to'][0x0],'ListId':_0x3b61b6['ListId']}));}}else{throw new Error('List\x20not\x20found');}}else{throw new Error(_0xbfd7('0xa5'));}})[_0xbfd7('0x20')](function(_0x2c8996){if(_0x2c8996){return db[_0xbfd7('0x6c')]['find']({'where':{'ContactId':_0x2c8996['id'],'closed':![],'FaxAccountId':_0x3b61b6['id']}})[_0xbfd7('0x20')](function(_0x423c7e){if(_0x423c7e){return[_0x423c7e,![]];}return db[_0xbfd7('0x6c')][_0xbfd7('0x56')]({'UserId':_0xfb95f7[_0xbfd7('0xa6')]['id'],'ContactId':_0x2c8996['id'],'FaxAccountId':_0x3b61b6['id'],'fax':_0xfb95f7[_0xbfd7('0x57')]['to'][0x0],'firstMsgDirection':_0xbfd7('0xa7'),'Messages':[_[_0xbfd7('0x4b')](_0xfb95f7['body'],{'read':![],'body':_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][0x0][_0xbfd7('0xa8')],'FaxAccountId':_0x3b61b6['id'],'UserId':_0xfb95f7[_0xbfd7('0xa6')]['id'],'ContactId':_0x2c8996['id'],'AttachmentId':_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][0x0]['id']})]},{'include':[{'model':db['FaxMessage'],'as':_0xbfd7('0xa9')}]})[_0xbfd7('0x20')](function(_0x8f797){return[_0x8f797,!![]];});});}else{throw new Error(_0xbfd7('0xaa'));}})[_0xbfd7('0xab')](function(_0x443855,_0x4b8e94){if(_0x4b8e94){return _0x443855;}return db[_0xbfd7('0x95')][_0xbfd7('0x56')]({'direction':'out','read':![],'body':_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][0x0][_0xbfd7('0xa8')],'FaxAccountId':_0x3b61b6['id'],'FaxInteractionId':_0x443855['id'],'UserId':_0xfb95f7[_0xbfd7('0xa6')]['id'],'ContactId':_0x443855['ContactId'],'AttachmentId':_0xfb95f7[_0xbfd7('0x57')][_0xbfd7('0x9d')][0x0]['id']})[_0xbfd7('0x20')](function(_0x241b3e){_0x443855['dataValues'][_0xbfd7('0xa9')]=[];_0x443855[_0xbfd7('0xac')][_0xbfd7('0xa9')]['push'](_0x241b3e['dataValues']);return _0x443855;});})[_0xbfd7('0x20')](function(_0x160e05){respondWithRpcPromise(_0xbfd7('0xad'),_0xbfd7('0xad'),{'FaxAccountId':_['isNil'](_0xfb95f7['params']['id'])?undefined:_0xfb95f7['params']['id'],'path':_[_0xbfd7('0xa2')](_0xfb95f7[_0xbfd7('0x57')]['attachments'][0x0][_0xbfd7('0x9')])?undefined:_0xfb95f7[_0xbfd7('0x57')]['attachments'][0x0][_0xbfd7('0x9')],'fax':_[_0xbfd7('0xa2')](_0xfb95f7['body']['to'][0x0])?undefined:_0xfb95f7[_0xbfd7('0x57')]['to'][0x0],'AttachmentId':_0xfb95f7[_0xbfd7('0x57')]['attachments'][0x0]['id']},client9002)[_0xbfd7('0x20')](function(_0x1659aa){logger['info'](_0xbfd7('0xae'),_0x1659aa);})[_0xbfd7('0x26')](function(_0xb0b7c9){logger[_0xbfd7('0x25')](_0xbfd7('0xae'),_0xb0b7c9);});return _0x160e05;})[_0xbfd7('0x20')](respondWithResult(_0x432440,null))['catch'](handleError(_0x432440,null));};exports[_0xbfd7('0xaf')]=function(_0x1e877c,_0x2cabf4,_0x24208a){return db['FaxAccount'][_0xbfd7('0x55')]({'where':{'id':_0x1e877c[_0xbfd7('0x52')]['id']}})[_0xbfd7('0x20')](handleEntityNotFound(_0x2cabf4,null))['then'](function(_0x7db69a){if(_0x7db69a){return _0x7db69a['addAgents'](_0x1e877c[_0xbfd7('0x57')]['ids'],_[_0xbfd7('0x90')](_0x1e877c['body'],[_0xbfd7('0x66'),'id'])||{})[_0xbfd7('0xab')](function(_0x3b050e){for(var _0x5bdebf=0x0;_0x5bdebf<_0x1e877c[_0xbfd7('0x57')]['ids'][_0xbfd7('0x45')];_0x5bdebf+=0x1){socket[_0xbfd7('0xb0')](_0xbfd7('0xb1'),{'UserId':_0x1e877c[_0xbfd7('0x57')][_0xbfd7('0x66')][_0x5bdebf],'FaxAccountId':_0x1e877c[_0xbfd7('0x52')]['id']});}return _0x3b050e;});}})[_0xbfd7('0x20')](respondWithResult(_0x2cabf4,null))[_0xbfd7('0x26')](handleError(_0x2cabf4,null));};exports[_0xbfd7('0xb2')]=function(_0x11b96d,_0x3a0e27,_0x495dbe){return db[_0xbfd7('0x39')][_0xbfd7('0x55')]({'where':{'id':_0x11b96d[_0xbfd7('0x52')]['id']}})['then'](handleEntityNotFound(_0x3a0e27,null))[_0xbfd7('0x20')](function(_0x5d9bee){if(_0x5d9bee){return _0x5d9bee[_0xbfd7('0xb2')](_0x11b96d[_0xbfd7('0x40')][_0xbfd7('0x66')])[_0xbfd7('0x20')](function(){if(_[_0xbfd7('0xb3')](_0x11b96d['query'][_0xbfd7('0x66')])){for(var _0x124c00=0x0;_0x124c00<_0x11b96d['query']['ids'][_0xbfd7('0x45')];_0x124c00+=0x1){socket[_0xbfd7('0xb0')](_0xbfd7('0xb4'),{'UserId':Number(_0x11b96d[_0xbfd7('0x40')][_0xbfd7('0x66')][_0x124c00]),'FaxAccountId':Number(_0x11b96d[_0xbfd7('0x52')]['id'])});}}else{socket[_0xbfd7('0xb0')](_0xbfd7('0xb4'),{'UserId':Number(_0x11b96d[_0xbfd7('0x40')][_0xbfd7('0x66')]),'FaxAccountId':Number(_0x11b96d['params']['id'])});}});}})[_0xbfd7('0x20')](respondWithStatusCode(_0x3a0e27,null))['catch'](handleError(_0x3a0e27,null));};exports[_0xbfd7('0xb5')]=function(_0x1f8dd5,_0x266dd1,_0x2ab0e0){var _0x2ef067={};var _0x191c7b={};var _0x165d23;var _0x24b9c0;return db['FaxAccount'][_0xbfd7('0x60')]({'where':{'id':_0x1f8dd5[_0xbfd7('0x52')]['id']}})['then'](handleEntityNotFound(_0x266dd1,null))[_0xbfd7('0x20')](function(_0xe3cdd2){if(_0xe3cdd2){_0x165d23=_0xe3cdd2;_0x191c7b[_0xbfd7('0x3e')]=_[_0xbfd7('0x53')](db[_0xbfd7('0x6f')][_0xbfd7('0x3a')]);_0x191c7b[_0xbfd7('0x40')]=_[_0xbfd7('0x53')](_0x1f8dd5[_0xbfd7('0x40')]);_0x191c7b[_0xbfd7('0x41')]=_[_0xbfd7('0x42')](_0x191c7b['model'],_0x191c7b[_0xbfd7('0x40')]);_0x2ef067[_0xbfd7('0x43')]=_[_0xbfd7('0x42')](_0x191c7b[_0xbfd7('0x3e')],qs['fields'](_0x1f8dd5[_0xbfd7('0x40')][_0xbfd7('0x44')]));_0x2ef067[_0xbfd7('0x43')]=_0x2ef067['attributes'][_0xbfd7('0x45')]?_0x2ef067[_0xbfd7('0x43')]:_0x191c7b[_0xbfd7('0x3e')];_0x2ef067[_0xbfd7('0x47')]=qs[_0xbfd7('0x48')](_0x1f8dd5[_0xbfd7('0x40')][_0xbfd7('0x48')]);_0x2ef067[_0xbfd7('0x4c')]=qs[_0xbfd7('0x41')](_[_0xbfd7('0x49')](_0x1f8dd5['query'],_0x191c7b[_0xbfd7('0x41')]));if(_0x1f8dd5[_0xbfd7('0x40')][_0xbfd7('0x4a')]){_0x2ef067[_0xbfd7('0x4c')]=_['merge'](_0x2ef067[_0xbfd7('0x4c')],{'$or':_[_0xbfd7('0x3f')](_0x2ef067[_0xbfd7('0x43')],function(_0x8e54e8){var _0x49796c={};_0x49796c[_0x8e54e8]={'$like':'%'+_0x1f8dd5[_0xbfd7('0x40')][_0xbfd7('0x4a')]+'%'};return _0x49796c;})});}_0x2ef067=_[_0xbfd7('0x4b')]({},_0x2ef067,_0x1f8dd5['options']);return _0x165d23[_0xbfd7('0xb5')](_0x2ef067);}})[_0xbfd7('0x20')](function(_0x2a8c5e){if(_0x2a8c5e){_0x24b9c0=_0x2a8c5e[_0xbfd7('0x45')];if(!_0x1f8dd5[_0xbfd7('0x40')]['hasOwnProperty'](_0xbfd7('0x46'))){_0x2ef067[_0xbfd7('0x2d')]=qs[_0xbfd7('0x2d')](_0x1f8dd5[_0xbfd7('0x40')][_0xbfd7('0x2d')]);_0x2ef067['offset']=qs['offset'](_0x1f8dd5[_0xbfd7('0x40')]['offset']);}return _0x165d23['getAgents'](_0x2ef067);}})['then'](function(_0x4e6db8){if(_0x4e6db8){return _0x4e6db8?{'count':_0x24b9c0,'rows':_0x4e6db8}:null;}})[_0xbfd7('0x20')](respondWithResult(_0x266dd1,null))[_0xbfd7('0x26')](handleError(_0x266dd1,null));};
\ No newline at end of file
+var _0x28d6=['sendStatus','name','send','Pause','map','FaxAccount','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','sort','where','filters','filter','merge','VIRTUAL','options','includeAll','params','find','create','user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','mandatoryDispositionPause','describe','addDisposition','FaxAccountId','Disposition','getDispositions','findOne','order','include','findAll','rows','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','hasOwnProperty','removeAnswers','FaxInteraction','addInteraction','getInteractions','pick','CmContact','Contact','User','Owner','fullname','internal','Tag','Tags','color','tag','sequelize','transaction','FaxApplication','bulkCreate','getApplications','from-voip-provider','exten','localstationid','app','system','description','priority','Answer','CDR(type)=inbound-fax','Set','ecm','faxdetect','maxrate','minrate','modem','t38timeout','push','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','addAccountApplications','VoiceExtension','createdAt','updatedAt','TrunkId','ListId','findById','getMessages','FaxMessage','$gte','split','format','List','Contacts','attachments','join','server/files/attachments','basename','CheckAfterSend','isNil','from','\x22%s\x22\x20<%s>','fax','Send\x20Fax\x20failed','out','filename','Messages','Contact\x20not\x20found','ContactId','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','emit','removeAgents','isArray','userFaxAccount:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','jayson/promise','client','http','request','then','info','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','FaxAccount,\x20%s,\x20%s','result','catch','end','json','count','offset','limit','status','set','update','destroy','get','FaxAccounts'];(function(_0x64aff8,_0x106082){var _0x5488a3=function(_0x36969c){while(--_0x36969c){_0x64aff8['push'](_0x64aff8['shift']());}};_0x5488a3(++_0x106082);}(_0x28d6,0x81));var _0x628d=function(_0x4a16aa,_0x46f661){_0x4a16aa=_0x4a16aa-0x0;var _0x4e9af4=_0x28d6[_0x4a16aa];return _0x4e9af4;};'use strict';var emlformat=require(_0x628d('0x0'));var rimraf=require(_0x628d('0x1'));var zipdir=require(_0x628d('0x2'));var jsonpatch=require(_0x628d('0x3'));var rp=require('request-promise');var moment=require(_0x628d('0x4'));var BPromise=require(_0x628d('0x5'));var Mustache=require(_0x628d('0x6'));var util=require(_0x628d('0x7'));var path=require(_0x628d('0x8'));var sox=require(_0x628d('0x9'));var csv=require('to-csv');var ejs=require(_0x628d('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x628d('0xb'));var jsforce=require(_0x628d('0xc'));var deskjs=require(_0x628d('0xd'));var toCsv=require(_0x628d('0xe'));var querystring=require(_0x628d('0xf'));var Papa=require('papaparse');var Redis=require(_0x628d('0x10'));var authService=require(_0x628d('0x11'));var qs=require(_0x628d('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x628d('0x13'));var logger=require(_0x628d('0x14'))(_0x628d('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x628d('0x16')]=_[_0x628d('0x17')](config['redis'],{'host':_0x628d('0x18'),'port':0x18eb});var socket=require(_0x628d('0x19'))(new Redis(config[_0x628d('0x16')]));require(_0x628d('0x1a'))['register'](socket);var jayson=require(_0x628d('0x1b'));var client=jayson[_0x628d('0x1c')][_0x628d('0x1d')]({'port':0x232c});var client9002=jayson[_0x628d('0x1c')][_0x628d('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x3680a8,_0x23b370,_0x5da258,_0x4c52a7){return new BPromise(function(_0xf8fb47,_0x4769a5){var _0xa4db01=_0x4c52a7||client;return _0xa4db01[_0x628d('0x1e')](_0x3680a8,_0x5da258)[_0x628d('0x1f')](function(_0x3c7ba5){logger[_0x628d('0x20')]('FaxAccount,\x20%s,\x20%s',_0x23b370,_0x628d('0x21'));logger[_0x628d('0x22')](_0x628d('0x23'),_0x23b370,_0x628d('0x21'),JSON[_0x628d('0x24')](_0x3c7ba5));if(_0x3c7ba5[_0x628d('0x25')]){if(_0x3c7ba5[_0x628d('0x25')][_0x628d('0x26')]===0x1f4){logger[_0x628d('0x25')]('FaxAccount,\x20%s,\x20%s',_0x23b370,_0x3c7ba5['error'][_0x628d('0x27')]);return _0x4769a5(_0x3c7ba5[_0x628d('0x25')][_0x628d('0x27')]);}logger[_0x628d('0x25')]('FaxAccount,\x20%s,\x20%s',_0x23b370,_0x3c7ba5[_0x628d('0x25')][_0x628d('0x27')]);return _0xf8fb47(_0x3c7ba5['error'][_0x628d('0x27')]);}else{logger[_0x628d('0x20')](_0x628d('0x28'),_0x23b370,_0x628d('0x21'));_0xf8fb47(_0x3c7ba5[_0x628d('0x29')][_0x628d('0x27')]);}})[_0x628d('0x2a')](function(_0x56b08e){logger[_0x628d('0x25')](_0x628d('0x28'),_0x23b370,_0x56b08e);_0x4769a5(_0x56b08e);});});}function respondWithStatusCode(_0xdb2989,_0x52ffa6){_0x52ffa6=_0x52ffa6||0xcc;return function(_0x4cd834){if(_0x4cd834){return _0xdb2989['sendStatus'](_0x52ffa6);}return _0xdb2989['status'](_0x52ffa6)[_0x628d('0x2b')]();};}function respondWithResult(_0x5a5d3e,_0x39ef76){_0x39ef76=_0x39ef76||0xc8;return function(_0x305db9){if(_0x305db9){return _0x5a5d3e['status'](_0x39ef76)[_0x628d('0x2c')](_0x305db9);}};}function respondWithFilteredResult(_0x25d9b1,_0x11d0d8){return function(_0xafb429){if(_0xafb429){var _0xf14cdc=_0xafb429[_0x628d('0x2d')],_0x595a68=_0x11d0d8[_0x628d('0x2e')],_0x246dfe=_0x11d0d8[_0x628d('0x2e')]+_0x11d0d8[_0x628d('0x2f')],_0x2aa41a;if(_0x246dfe>=_0xf14cdc){_0x246dfe=_0xf14cdc;_0x2aa41a=0xc8;}else{_0x2aa41a=0xce;}_0x25d9b1[_0x628d('0x30')](_0x2aa41a);return _0x25d9b1[_0x628d('0x31')]('Content-Range',_0x595a68+'-'+_0x246dfe+'/'+_0xf14cdc)[_0x628d('0x2c')](_0xafb429);}return null;};}function patchUpdates(_0x59e7da){return function(_0x99885){try{jsonpatch['apply'](_0x99885,_0x59e7da,!![]);}catch(_0x3bf63b){return BPromise['reject'](_0x3bf63b);}return _0x99885['save']();};}function saveUpdates(_0x48148d,_0x1aefa1){return function(_0x297773){if(_0x297773){return _0x297773[_0x628d('0x32')](_0x48148d)[_0x628d('0x1f')](function(_0x1cb7e9){return _0x1cb7e9;});}return null;};}function removeEntity(_0x3e1b9f,_0x208c4c){return function(_0x43d409){if(_0x43d409){return _0x43d409[_0x628d('0x33')]()['then'](function(){var _0x3909a0=_0x43d409[_0x628d('0x34')]({'plain':!![]});var _0x5442e6=_0x628d('0x35');return db['UserProfileResource'][_0x628d('0x33')]({'where':{'type':_0x5442e6,'resourceId':_0x3909a0['id']}})['then'](function(){return _0x43d409;});})[_0x628d('0x1f')](function(){_0x3e1b9f[_0x628d('0x30')](0xcc)[_0x628d('0x2b')]();});}};}function handleEntityNotFound(_0x36ef8d,_0x10aeaf){return function(_0x2cc151){if(!_0x2cc151){_0x36ef8d[_0x628d('0x36')](0x194);}return _0x2cc151;};}function handleError(_0x8a8e57,_0x4ed64d){_0x4ed64d=_0x4ed64d||0x1f4;return function(_0x59ed0b){logger[_0x628d('0x25')](_0x59ed0b['stack']);if(_0x59ed0b[_0x628d('0x37')]){delete _0x59ed0b[_0x628d('0x37')];}_0x8a8e57[_0x628d('0x30')](_0x4ed64d)[_0x628d('0x38')](_0x59ed0b);};}exports['index']=function(_0x1f445c,_0x548e18){var _0x3a26dd={'include':[{'model':db[_0x628d('0x39')],'as':'mandatoryDispositionPause'}]},_0x809c85={},_0x2363b9={'count':0x0,'rows':[]};var _0x26ade1=_[_0x628d('0x3a')](db[_0x628d('0x3b')][_0x628d('0x3c')],function(_0x3cb7a3){return{'name':_0x3cb7a3[_0x628d('0x3d')],'type':_0x3cb7a3[_0x628d('0x3e')][_0x628d('0x3f')]};});_0x809c85[_0x628d('0x40')]=_['map'](_0x26ade1,_0x628d('0x37'));_0x809c85[_0x628d('0x41')]=_[_0x628d('0x42')](_0x1f445c[_0x628d('0x41')]);_0x809c85['filters']=_[_0x628d('0x43')](_0x809c85[_0x628d('0x40')],_0x809c85[_0x628d('0x41')]);_0x3a26dd[_0x628d('0x44')]=_[_0x628d('0x43')](_0x809c85['model'],qs[_0x628d('0x45')](_0x1f445c[_0x628d('0x41')]['fields']));_0x3a26dd['attributes']=_0x3a26dd[_0x628d('0x44')][_0x628d('0x46')]?_0x3a26dd[_0x628d('0x44')]:_0x809c85[_0x628d('0x40')];if(!_0x1f445c[_0x628d('0x41')]['hasOwnProperty'](_0x628d('0x47'))){_0x3a26dd[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0x1f445c['query'][_0x628d('0x2f')]);_0x3a26dd['offset']=qs[_0x628d('0x2e')](_0x1f445c[_0x628d('0x41')]['offset']);}_0x3a26dd['order']=qs['sort'](_0x1f445c[_0x628d('0x41')][_0x628d('0x48')]);_0x3a26dd[_0x628d('0x49')]=qs[_0x628d('0x4a')](_['pick'](_0x1f445c[_0x628d('0x41')],_0x809c85[_0x628d('0x4a')]),_0x26ade1);if(_0x1f445c[_0x628d('0x41')][_0x628d('0x4b')]){_0x3a26dd[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x3a26dd['where'],{'$or':_[_0x628d('0x3a')](_0x26ade1,function(_0x4a8e65){if(_0x4a8e65['type']!==_0x628d('0x4d')){var _0x58637c={};_0x58637c[_0x4a8e65[_0x628d('0x37')]]={'$like':'%'+_0x1f445c[_0x628d('0x41')]['filter']+'%'};return _0x58637c;}})});}_0x3a26dd=_[_0x628d('0x4c')]({},_0x3a26dd,_0x1f445c[_0x628d('0x4e')]);var _0x5bb64a={'where':_0x3a26dd[_0x628d('0x49')]};return db[_0x628d('0x3b')]['count'](_0x5bb64a)[_0x628d('0x1f')](function(_0x53da93){_0x2363b9[_0x628d('0x2d')]=_0x53da93;if(_0x1f445c[_0x628d('0x41')][_0x628d('0x4f')]){_0x3a26dd['include']=[{'all':!![]}];}return db[_0x628d('0x3b')]['findAll'](_0x3a26dd);})['then'](function(_0x4444b0){_0x2363b9['rows']=_0x4444b0;return _0x2363b9;})[_0x628d('0x1f')](respondWithFilteredResult(_0x548e18,_0x3a26dd))[_0x628d('0x2a')](handleError(_0x548e18,null));};exports['show']=function(_0x3683db,_0x484da4){var _0x1d7431={'raw':![],'where':{'id':_0x3683db[_0x628d('0x50')]['id']},'include':[{'model':db[_0x628d('0x39')],'as':'mandatoryDispositionPause'}]},_0xefa316={};_0xefa316[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x3b')]['rawAttributes']);_0xefa316['query']=_[_0x628d('0x42')](_0x3683db['query']);_0xefa316[_0x628d('0x4a')]=_['intersection'](_0xefa316[_0x628d('0x40')],_0xefa316['query']);_0x1d7431[_0x628d('0x44')]=_['intersection'](_0xefa316[_0x628d('0x40')],qs['fields'](_0x3683db['query'][_0x628d('0x45')]));_0x1d7431[_0x628d('0x44')]=_0x1d7431[_0x628d('0x44')][_0x628d('0x46')]?_0x1d7431[_0x628d('0x44')]:_0xefa316[_0x628d('0x40')];if(_0x3683db[_0x628d('0x41')]['includeAll']){_0x1d7431['include']=[{'all':!![]}];}_0x1d7431=_[_0x628d('0x4c')]({},_0x1d7431,_0x3683db[_0x628d('0x4e')]);return db['FaxAccount'][_0x628d('0x51')](_0x1d7431)[_0x628d('0x1f')](handleEntityNotFound(_0x484da4,null))[_0x628d('0x1f')](respondWithResult(_0x484da4,null))[_0x628d('0x2a')](handleError(_0x484da4,null));};exports[_0x628d('0x52')]=function(_0x443fe2,_0x19ba95){return db['FaxAccount'][_0x628d('0x52')](_0x443fe2['body'],{})[_0x628d('0x1f')](function(_0x49382e){var _0x153d42=_0x443fe2[_0x628d('0x53')][_0x628d('0x34')]({'plain':!![]});if(!_0x153d42)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x153d42[_0x628d('0x54')]===_0x628d('0x53')){var _0x698124=_0x49382e['get']({'plain':!![]});var _0x4a47f7=_0x628d('0x35');return db[_0x628d('0x55')][_0x628d('0x51')]({'where':{'name':_0x4a47f7,'userProfileId':_0x153d42[_0x628d('0x56')]},'raw':!![]})['then'](function(_0x238918){if(_0x238918&&_0x238918['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x698124[_0x628d('0x37')],'resourceId':_0x698124['id'],'type':_0x238918[_0x628d('0x37')],'sectionId':_0x238918['id']},{})[_0x628d('0x1f')](function(){return _0x49382e;});}else{return _0x49382e;}})[_0x628d('0x2a')](function(_0x2680cf){logger[_0x628d('0x25')](_0x628d('0x57'),_0x2680cf);throw _0x2680cf;});}return _0x49382e;})[_0x628d('0x1f')](respondWithResult(_0x19ba95,0xc9))[_0x628d('0x2a')](handleError(_0x19ba95,null));};exports[_0x628d('0x32')]=function(_0x1a79a1,_0x3fca63){if(_0x1a79a1[_0x628d('0x58')]['id']){delete _0x1a79a1[_0x628d('0x58')]['id'];}return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x1a79a1['params']['id']},'include':[{'model':db[_0x628d('0x39')],'as':_0x628d('0x59')}]})[_0x628d('0x1f')](handleEntityNotFound(_0x3fca63,null))[_0x628d('0x1f')](saveUpdates(_0x1a79a1['body'],null))[_0x628d('0x1f')](respondWithResult(_0x3fca63,null))['catch'](handleError(_0x3fca63,null));};exports['destroy']=function(_0x3e6ec9,_0x4ed757){return db[_0x628d('0x3b')][_0x628d('0x51')]({'where':{'id':_0x3e6ec9['params']['id']}})['then'](handleEntityNotFound(_0x4ed757,null))[_0x628d('0x1f')](removeEntity(_0x4ed757,null))['catch'](handleError(_0x4ed757,null));};exports[_0x628d('0x5a')]=function(_0x19f446,_0x3088f6){return db[_0x628d('0x3b')][_0x628d('0x5a')]()['then'](respondWithResult(_0x3088f6,null))['catch'](handleError(_0x3088f6,null));};exports[_0x628d('0x5b')]=function(_0x2293bf,_0x1fa564,_0x1f0fdb){if(_0x2293bf['body']['id']){delete _0x2293bf['body']['id'];}return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x2293bf[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x1fa564,null))['then'](function(_0x3e2d85){if(_0x3e2d85){_0x2293bf['body'][_0x628d('0x5c')]=_0x3e2d85['id'];return db[_0x628d('0x5d')][_0x628d('0x52')](_0x2293bf[_0x628d('0x58')]);}})['then'](respondWithResult(_0x1fa564,null))['catch'](handleError(_0x1fa564,null));};exports[_0x628d('0x5e')]=function(_0x4ba9de,_0x4647bc,_0x5a18a8){var _0x59e871={'raw':![],'where':{}};var _0x4c8345={};var _0x56398e={'count':0x0,'rows':[]};return db[_0x628d('0x3b')][_0x628d('0x5f')]({'where':{'id':_0x4ba9de['params']['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x4647bc,null))[_0x628d('0x1f')](function(_0x2d34e7){if(_0x2d34e7){_0x4c8345[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x5d')][_0x628d('0x3c')]);_0x4c8345['query']=_[_0x628d('0x42')](_0x4ba9de['query']);_0x4c8345['filters']=_[_0x628d('0x43')](_0x4c8345[_0x628d('0x40')],_0x4c8345[_0x628d('0x41')]);_0x59e871[_0x628d('0x44')]=_[_0x628d('0x43')](_0x4c8345['model'],qs[_0x628d('0x45')](_0x4ba9de[_0x628d('0x41')][_0x628d('0x45')]));_0x59e871['attributes']=_0x59e871[_0x628d('0x44')][_0x628d('0x46')]?_0x59e871[_0x628d('0x44')]:_0x4c8345['model'];if(!_0x4ba9de[_0x628d('0x41')]['hasOwnProperty'](_0x628d('0x47'))){_0x59e871[_0x628d('0x2f')]=qs['limit'](_0x4ba9de[_0x628d('0x41')][_0x628d('0x2f')]);_0x59e871[_0x628d('0x2e')]=qs[_0x628d('0x2e')](_0x4ba9de[_0x628d('0x41')][_0x628d('0x2e')]);}_0x59e871[_0x628d('0x60')]=qs[_0x628d('0x48')](_0x4ba9de['query'][_0x628d('0x48')]);_0x59e871[_0x628d('0x49')]=qs['filters'](_['pick'](_0x4ba9de[_0x628d('0x41')],_0x4c8345[_0x628d('0x4a')]));_0x59e871[_0x628d('0x49')][_0x628d('0x5c')]=_0x2d34e7['id'];if(_0x4ba9de[_0x628d('0x41')]['filter']){_0x59e871[_0x628d('0x49')]=_['merge'](_0x59e871[_0x628d('0x49')],{'$or':_[_0x628d('0x3a')](_0x59e871[_0x628d('0x44')],function(_0x39a724){var _0x20569c={};_0x20569c[_0x39a724]={'$like':'%'+_0x4ba9de[_0x628d('0x41')]['filter']+'%'};return _0x20569c;})});}_0x59e871=_[_0x628d('0x4c')]({},_0x59e871,_0x4ba9de[_0x628d('0x4e')]);return db[_0x628d('0x5d')][_0x628d('0x2d')]({'where':_0x59e871['where']})['then'](function(_0x44c461){_0x56398e[_0x628d('0x2d')]=_0x44c461;if(_0x4ba9de['query']['includeAll']){_0x59e871[_0x628d('0x61')]=[{'all':!![]}];}return db[_0x628d('0x5d')][_0x628d('0x62')](_0x59e871);})['then'](function(_0x151678){_0x56398e[_0x628d('0x63')]=_0x151678;return _0x56398e;});}})['then'](respondWithFilteredResult(_0x4647bc,_0x59e871))[_0x628d('0x2a')](handleError(_0x4647bc,null));};exports[_0x628d('0x64')]=function(_0x5ad265,_0x4c74a1,_0x31ba24){return db[_0x628d('0x3b')][_0x628d('0x51')]({'where':{'id':_0x5ad265[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x4c74a1,null))[_0x628d('0x1f')](function(_0x2f5db2){if(_0x2f5db2){return _0x2f5db2['removeDispositions'](_0x5ad265[_0x628d('0x41')][_0x628d('0x65')]);}})[_0x628d('0x1f')](respondWithStatusCode(_0x4c74a1,null))[_0x628d('0x2a')](handleError(_0x4c74a1,null));};exports[_0x628d('0x66')]=function(_0x3cc3b1,_0x15474c,_0x4702e0){if(_0x3cc3b1['body']['id']){delete _0x3cc3b1[_0x628d('0x58')]['id'];}return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x3cc3b1[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x15474c,null))[_0x628d('0x1f')](function(_0x20afd7){if(_0x20afd7){_0x3cc3b1[_0x628d('0x58')]['FaxAccountId']=_0x20afd7['id'];return db[_0x628d('0x67')][_0x628d('0x52')](_0x3cc3b1[_0x628d('0x58')]);}})['then'](respondWithResult(_0x15474c,null))['catch'](handleError(_0x15474c,null));};exports[_0x628d('0x68')]=function(_0x3105c2,_0x41b18a,_0x1382fb){var _0xae651c={'raw':![],'where':{}};var _0x39fc7e={};var _0x4f6150={'count':0x0,'rows':[]};return db[_0x628d('0x3b')]['findOne']({'where':{'id':_0x3105c2['params']['id']}})['then'](handleEntityNotFound(_0x41b18a,null))['then'](function(_0x11673a){if(_0x11673a){_0x39fc7e[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x67')]['rawAttributes']);_0x39fc7e[_0x628d('0x41')]=_[_0x628d('0x42')](_0x3105c2[_0x628d('0x41')]);_0x39fc7e['filters']=_[_0x628d('0x43')](_0x39fc7e[_0x628d('0x40')],_0x39fc7e[_0x628d('0x41')]);_0xae651c[_0x628d('0x44')]=_[_0x628d('0x43')](_0x39fc7e['model'],qs[_0x628d('0x45')](_0x3105c2['query'][_0x628d('0x45')]));_0xae651c[_0x628d('0x44')]=_0xae651c[_0x628d('0x44')][_0x628d('0x46')]?_0xae651c[_0x628d('0x44')]:_0x39fc7e[_0x628d('0x40')];if(!_0x3105c2[_0x628d('0x41')][_0x628d('0x69')](_0x628d('0x47'))){_0xae651c[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0x3105c2[_0x628d('0x41')][_0x628d('0x2f')]);_0xae651c[_0x628d('0x2e')]=qs['offset'](_0x3105c2[_0x628d('0x41')][_0x628d('0x2e')]);}_0xae651c[_0x628d('0x60')]=qs['sort'](_0x3105c2['query'][_0x628d('0x48')]);_0xae651c[_0x628d('0x49')]=qs['filters'](_['pick'](_0x3105c2[_0x628d('0x41')],_0x39fc7e[_0x628d('0x4a')]));_0xae651c['where'][_0x628d('0x5c')]=_0x11673a['id'];if(_0x3105c2[_0x628d('0x41')]['filter']){_0xae651c[_0x628d('0x49')]=_[_0x628d('0x4c')](_0xae651c['where'],{'$or':_[_0x628d('0x3a')](_0xae651c[_0x628d('0x44')],function(_0xe67981){var _0x501275={};_0x501275[_0xe67981]={'$like':'%'+_0x3105c2['query']['filter']+'%'};return _0x501275;})});}_0xae651c=_[_0x628d('0x4c')]({},_0xae651c,_0x3105c2[_0x628d('0x4e')]);return db['CannedAnswer'][_0x628d('0x2d')]({'where':_0xae651c[_0x628d('0x49')]})['then'](function(_0xaeac8d){_0x4f6150[_0x628d('0x2d')]=_0xaeac8d;if(_0x3105c2[_0x628d('0x41')][_0x628d('0x4f')]){_0xae651c[_0x628d('0x61')]=[{'all':!![]}];}return db['CannedAnswer'][_0x628d('0x62')](_0xae651c);})[_0x628d('0x1f')](function(_0x55384e){_0x4f6150[_0x628d('0x63')]=_0x55384e;return _0x4f6150;});}})[_0x628d('0x1f')](respondWithFilteredResult(_0x41b18a,_0xae651c))['catch'](handleError(_0x41b18a,null));};exports[_0x628d('0x6a')]=function(_0x4ddeb1,_0x225c59,_0x4fb16d){return db[_0x628d('0x3b')][_0x628d('0x51')]({'where':{'id':_0x4ddeb1[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x225c59,null))[_0x628d('0x1f')](function(_0x5c81e0){if(_0x5c81e0){return _0x5c81e0[_0x628d('0x6a')](_0x4ddeb1[_0x628d('0x41')][_0x628d('0x65')]);}})[_0x628d('0x1f')](respondWithStatusCode(_0x225c59,null))[_0x628d('0x2a')](handleError(_0x225c59,null));};exports['addInteraction']=function(_0x67c2d5,_0x11339f,_0x2f57ac){return db[_0x628d('0x6b')][_0x628d('0x51')]({'where':{'id':_0x67c2d5[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x11339f,null))['then'](function(_0x1c9124){if(_0x1c9124){return _0x1c9124[_0x628d('0x6c')](_0x67c2d5['body']['ids'],_['omit'](_0x67c2d5[_0x628d('0x58')],[_0x628d('0x65'),'id'])||{});}})[_0x628d('0x1f')](respondWithResult(_0x11339f,null))[_0x628d('0x2a')](handleError(_0x11339f,null));};exports[_0x628d('0x6d')]=function(_0x12e593,_0x41631a,_0x48f8c8){var _0x206597={'raw':![],'where':{}};var _0x55783c={};var _0x11e3f5={'count':0x0,'rows':[]};return db[_0x628d('0x3b')][_0x628d('0x5f')]({'where':{'id':_0x12e593[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x41631a,null))[_0x628d('0x1f')](function(_0x32a2ae){if(_0x32a2ae){_0x55783c[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x6b')]['rawAttributes']);_0x55783c[_0x628d('0x41')]=_[_0x628d('0x42')](_0x12e593[_0x628d('0x41')]);_0x55783c['filters']=_['intersection'](_0x55783c[_0x628d('0x40')],_0x55783c['query']);_0x206597[_0x628d('0x44')]=_[_0x628d('0x43')](_0x55783c['model'],qs[_0x628d('0x45')](_0x12e593[_0x628d('0x41')][_0x628d('0x45')]));_0x206597[_0x628d('0x44')]=_0x206597[_0x628d('0x44')][_0x628d('0x46')]?_0x206597[_0x628d('0x44')]:_0x55783c[_0x628d('0x40')];if(!_0x12e593[_0x628d('0x41')][_0x628d('0x69')](_0x628d('0x47'))){_0x206597['limit']=qs[_0x628d('0x2f')](_0x12e593[_0x628d('0x41')][_0x628d('0x2f')]);_0x206597[_0x628d('0x2e')]=qs[_0x628d('0x2e')](_0x12e593[_0x628d('0x41')][_0x628d('0x2e')]);}_0x206597[_0x628d('0x60')]=qs[_0x628d('0x48')](_0x12e593[_0x628d('0x41')][_0x628d('0x48')]);_0x206597['where']=qs[_0x628d('0x4a')](_[_0x628d('0x6e')](_0x12e593[_0x628d('0x41')],_0x55783c[_0x628d('0x4a')]));_0x206597['where'][_0x628d('0x5c')]=_0x32a2ae['id'];if(_0x12e593[_0x628d('0x41')]['filter']){_0x206597[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x206597['where'],{'$or':_[_0x628d('0x3a')](_0x206597[_0x628d('0x44')],function(_0x2c90f8){var _0xbe13b8={};_0xbe13b8[_0x2c90f8]={'$like':'%'+_0x12e593['query']['filter']+'%'};return _0xbe13b8;})});}_0x206597=_[_0x628d('0x4c')]({},_0x206597,_0x12e593[_0x628d('0x4e')]);return db[_0x628d('0x6b')][_0x628d('0x2d')]({'where':_0x206597[_0x628d('0x49')]})[_0x628d('0x1f')](function(_0x11f162){_0x11e3f5['count']=_0x11f162;if(_0x12e593['query'][_0x628d('0x4f')]){_0x206597['include']=[{'model':db[_0x628d('0x6f')],'as':_0x628d('0x70'),'required':![]},{'model':db[_0x628d('0x71')],'as':_0x628d('0x72'),'attributes':[_0x628d('0x37'),_0x628d('0x73'),_0x628d('0x74')],'required':![]},{'model':db[_0x628d('0x75')],'as':_0x628d('0x76'),'attributes':['id',_0x628d('0x37'),_0x628d('0x77')],'where':_0x12e593[_0x628d('0x41')][_0x628d('0x78')]?{'id':_0x12e593['query'][_0x628d('0x78')]}:undefined,'required':_0x12e593[_0x628d('0x41')]['tag']?!![]:![]}];}return db[_0x628d('0x6b')]['findAll'](_0x206597);})['then'](function(_0x52ade0){_0x11e3f5[_0x628d('0x63')]=_0x52ade0;return _0x11e3f5;});}})[_0x628d('0x1f')](respondWithFilteredResult(_0x41631a,_0x206597))[_0x628d('0x2a')](handleError(_0x41631a,null));};exports['addApplications']=function(_0x3ca76a,_0xf308c0,_0x94a838){return db[_0x628d('0x3b')][_0x628d('0x5f')]({'where':{'id':_0x3ca76a[_0x628d('0x50')]['id']}})['then'](handleEntityNotFound(_0xf308c0,null))['then'](function(_0x347c3c){if(_0x347c3c){return db[_0x628d('0x79')][_0x628d('0x7a')](function(_0x2d064b){return db[_0x628d('0x7b')][_0x628d('0x33')]({'where':{'FaxAccountId':_0x3ca76a[_0x628d('0x50')]['id']},'transaction':_0x2d064b})[_0x628d('0x1f')](function(_0x39db16){var _0x43c999=_['map'](_0x3ca76a[_0x628d('0x58')],function(_0x304574){_0x304574['FaxAccountId']=_0x3ca76a['params']['id'];return _0x304574;});return db[_0x628d('0x7b')][_0x628d('0x7c')](_0x43c999,{'transaction':_0x2d064b});});})[_0x628d('0x1f')](function(){return db[_0x628d('0x7b')]['findAndCountAll']({'where':{'FaxAccountId':_0x3ca76a[_0x628d('0x50')]['id']},'order':'priority'});});}})[_0x628d('0x1f')](respondWithResult(_0xf308c0,null))['catch'](handleError(_0xf308c0,null));};exports[_0x628d('0x7d')]=function(_0x27e59c,_0x1bac4a,_0x553073){var _0x50fd72={};var _0x227a6b={};var _0x1e1ce7;var _0x82ff66;return db['FaxAccount'][_0x628d('0x5f')]({'where':{'id':_0x27e59c['params']['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x1bac4a,null))[_0x628d('0x1f')](function(_0x478f46){if(_0x478f46){_0x1e1ce7=_0x478f46;_0x227a6b[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x7b')][_0x628d('0x3c')]);_0x227a6b[_0x628d('0x41')]=_[_0x628d('0x42')](_0x27e59c[_0x628d('0x41')]);_0x227a6b[_0x628d('0x4a')]=_[_0x628d('0x43')](_0x227a6b[_0x628d('0x40')],_0x227a6b[_0x628d('0x41')]);_0x50fd72[_0x628d('0x44')]=_[_0x628d('0x43')](_0x227a6b[_0x628d('0x40')],qs[_0x628d('0x45')](_0x27e59c[_0x628d('0x41')]['fields']));_0x50fd72[_0x628d('0x44')]=_0x50fd72[_0x628d('0x44')][_0x628d('0x46')]?_0x50fd72['attributes']:_0x227a6b[_0x628d('0x40')];_0x50fd72[_0x628d('0x60')]=qs[_0x628d('0x48')](_0x27e59c[_0x628d('0x41')][_0x628d('0x48')]);_0x50fd72['where']=qs[_0x628d('0x4a')](_[_0x628d('0x6e')](_0x27e59c['query'],_0x227a6b[_0x628d('0x4a')]));if(_0x27e59c[_0x628d('0x41')][_0x628d('0x4b')]){_0x50fd72[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x50fd72[_0x628d('0x49')],{'$or':_['map'](_0x50fd72[_0x628d('0x44')],function(_0x296113){var _0x127bb8={};_0x127bb8[_0x296113]={'$like':'%'+_0x27e59c['query'][_0x628d('0x4b')]+'%'};return _0x127bb8;})});}_0x50fd72=_['merge']({},_0x50fd72,_0x27e59c[_0x628d('0x4e')]);return _0x1e1ce7['getApplications'](_0x50fd72);}})[_0x628d('0x1f')](function(_0xd0e698){if(_0xd0e698){_0x82ff66=_0xd0e698['length'];if(!_0x27e59c['query']['hasOwnProperty'](_0x628d('0x47'))){_0x50fd72[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0x27e59c[_0x628d('0x41')][_0x628d('0x2f')]);_0x50fd72[_0x628d('0x2e')]=qs[_0x628d('0x2e')](_0x27e59c[_0x628d('0x41')]['offset']);}return _0x1e1ce7[_0x628d('0x7d')](_0x50fd72);}})[_0x628d('0x1f')](function(_0x574d6e){if(_0x574d6e){return _0x574d6e?{'count':_0x82ff66,'rows':_0x574d6e}:null;}})[_0x628d('0x1f')](respondWithResult(_0x1bac4a,null))[_0x628d('0x2a')](handleError(_0x1bac4a,null));};function Extension(_0x979516,_0x1d85c9,_0x3c9ce9,_0x4e8ad1){this['context']=_0x628d('0x7e');this[_0x628d('0x7f')]=_0x979516[_0x628d('0x80')];this[_0x628d('0x81')]=_0x4e8ad1;this[_0x628d('0x3e')]=_0x628d('0x82');this[_0x628d('0x83')]='Fax\x20Extension';this['FaxAccountId']=_0x979516['id'];this[_0x628d('0x84')]=_0x1d85c9;this['appdata']=_0x3c9ce9;}function createExtensionsReciveFax(_0x1c4ee8){var _0x4d5519=0x1;var _0x20d9bb=[];_0x20d9bb['push'](new Extension(_0x1c4ee8,_0x4d5519,'',_0x628d('0x85')));_0x4d5519+=0x1;_0x20d9bb['push'](new Extension(_0x1c4ee8,_0x4d5519,_0x628d('0x86'),_0x628d('0x87')));_0x4d5519+=0x1;for(var _0x32c0e0 in _0x1c4ee8){if(_0x1c4ee8[_0x628d('0x69')](_0x32c0e0)&&(_0x32c0e0===_0x628d('0x88')||_0x32c0e0===_0x628d('0x80')||_0x32c0e0==='gateway'||_0x32c0e0===_0x628d('0x89')||_0x32c0e0==='headerinfo'||_0x32c0e0===_0x628d('0x8a')||_0x32c0e0===_0x628d('0x8b')||_0x32c0e0===_0x628d('0x8c')||_0x32c0e0===_0x628d('0x8d'))){_0x20d9bb[_0x628d('0x8e')](new Extension(_0x1c4ee8,_0x4d5519,'FAXOPT('+_0x32c0e0+')='+_0x1c4ee8[_0x32c0e0],_0x628d('0x87')));_0x4d5519+=0x1;}}_0x20d9bb[_0x628d('0x8e')](new Extension(_0x1c4ee8,_0x4d5519,'6',_0x628d('0x8f')));_0x4d5519+=0x1;_0x20d9bb[_0x628d('0x8e')](new Extension(_0x1c4ee8,_0x4d5519,_0x628d('0x90'),'ReceiveFax'));_0x4d5519=0x0;return _0x20d9bb;}exports[_0x628d('0x91')]=function(_0x4a7f40,_0x5bbdf1,_0x49fde2){var _0x403e8a;return db['sequelize'][_0x628d('0x7a')](function(_0x5df29b){return db[_0x628d('0x3b')][_0x628d('0x52')](_0x4a7f40['body'],{'transaction':_0x5df29b})[_0x628d('0x1f')](function(_0x9f4119){_0x403e8a=_0x9f4119[_0x628d('0x34')]({'plain':!![]});return db[_0x628d('0x92')][_0x628d('0x7c')](createExtensionsReciveFax(_0x403e8a),{'transaction':_0x5df29b});});})[_0x628d('0x1f')](function(){return _0x403e8a;})[_0x628d('0x1f')](respondWithResult(_0x5bbdf1,null))[_0x628d('0x2a')](handleError(_0x5bbdf1,null));};exports['updateAccountApplications']=function(_0x350033,_0x311ed6,_0x84e68c){var _0x155895;return db[_0x628d('0x79')][_0x628d('0x7a')](function(_0x4a5c6d){return db[_0x628d('0x3b')][_0x628d('0x32')](_0x350033[_0x628d('0x58')],{'where':{'id':_0x350033[_0x628d('0x58')]['id']},'transaction':_0x4a5c6d})[_0x628d('0x1f')](function(_0x11e6b5){return db[_0x628d('0x92')][_0x628d('0x33')]({'where':{'FaxAccountId':_0x350033[_0x628d('0x58')]['id']},'transaction':_0x4a5c6d})[_0x628d('0x1f')](function(_0x146ca9){return db[_0x628d('0x92')][_0x628d('0x7c')](createExtensionsReciveFax(_['omit'](_0x350033[_0x628d('0x58')],['tech','key',_0x628d('0x93'),_0x628d('0x94'),_0x628d('0x95'),_0x628d('0x96')])),{'transaction':_0x4a5c6d});});});})[_0x628d('0x1f')](function(){return db[_0x628d('0x3b')][_0x628d('0x97')](_0x350033[_0x628d('0x58')]['id']);})[_0x628d('0x1f')](respondWithResult(_0x311ed6,null))['catch'](handleError(_0x311ed6,null));};exports[_0x628d('0x98')]=function(_0x293412,_0x3ed86b,_0x1a0047){var _0x369a6c={'raw':!![],'where':{}};var _0x5e1c63={};var _0x497d84={'count':0x0,'rows':[]};return db['FaxAccount'][_0x628d('0x5f')]({'where':{'id':_0x293412['params']['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x3ed86b,null))['then'](function(_0x1ee4ce){if(_0x1ee4ce){_0x5e1c63[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x99')][_0x628d('0x3c')]);_0x5e1c63[_0x628d('0x41')]=_[_0x628d('0x42')](_0x293412[_0x628d('0x41')]);_0x5e1c63[_0x628d('0x4a')]=_[_0x628d('0x43')](_0x5e1c63['model'],_0x5e1c63[_0x628d('0x41')]);_0x369a6c[_0x628d('0x44')]=_['intersection'](_0x5e1c63[_0x628d('0x40')],qs[_0x628d('0x45')](_0x293412['query'][_0x628d('0x45')]));_0x369a6c[_0x628d('0x44')]=_0x369a6c['attributes'][_0x628d('0x46')]?_0x369a6c[_0x628d('0x44')]:_0x5e1c63['model'];if(!_0x293412[_0x628d('0x41')][_0x628d('0x69')]('nolimit')){_0x369a6c[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0x293412[_0x628d('0x41')][_0x628d('0x2f')]);_0x369a6c[_0x628d('0x2e')]=qs['offset'](_0x293412['query'][_0x628d('0x2e')]);}_0x369a6c['order']=qs[_0x628d('0x48')](_0x293412['query'][_0x628d('0x48')]);_0x369a6c[_0x628d('0x49')]=qs[_0x628d('0x4a')](_[_0x628d('0x6e')](_0x293412[_0x628d('0x41')],_0x5e1c63['filters']));_0x369a6c['where'][_0x628d('0x5c')]=_0x1ee4ce['id'];if(_0x293412[_0x628d('0x41')]['filter']){_0x369a6c[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x369a6c[_0x628d('0x49')],{'$or':_['map'](_0x369a6c[_0x628d('0x44')],function(_0x1bca26){var _0x54c40f={};_0x54c40f[_0x1bca26]={'$like':'%'+_0x293412[_0x628d('0x41')][_0x628d('0x4b')]+'%'};return _0x54c40f;})});}if(_0x293412['query'][_0x628d('0x9a')]){var _0x245f22=_0x293412[_0x628d('0x41')][_0x628d('0x9a')][_0x628d('0x9b')](',');var _0x49dc60={};_0x49dc60[_0x245f22[0x0]]={'$gte':moment(_0x245f22[0x1])[_0x628d('0x9c')]('YYYY-MM-DD\x20HH:mm:ss')};_0x369a6c[_0x628d('0x49')]=_['merge'](_0x369a6c[_0x628d('0x49')],_0x49dc60);}_0x369a6c=_[_0x628d('0x4c')]({},_0x369a6c,_0x293412['options']);return db['FaxMessage'][_0x628d('0x2d')]({'where':_0x369a6c[_0x628d('0x49')]})[_0x628d('0x1f')](function(_0x56380){_0x497d84[_0x628d('0x2d')]=_0x56380;if(_0x293412[_0x628d('0x41')][_0x628d('0x4f')]){_0x369a6c['include']=[{'all':!![]}];}return db[_0x628d('0x99')][_0x628d('0x62')](_0x369a6c);})[_0x628d('0x1f')](function(_0x1c0316){_0x497d84[_0x628d('0x63')]=_0x1c0316;return _0x497d84;});}})['then'](respondWithFilteredResult(_0x3ed86b,_0x369a6c))[_0x628d('0x2a')](handleError(_0x3ed86b,null));};exports[_0x628d('0x38')]=function(_0x318590,_0x454f1a,_0x354230){var _0x116504,_0x1e00d4={},_0x295977;if(_0x318590[_0x628d('0x58')]['to']){_0x295977=_0x318590[_0x628d('0x58')]['to'][0x0];}return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x318590[_0x628d('0x50')]['id']},'include':[{'model':db['CmList'],'as':_0x628d('0x9d'),'include':[{'model':db[_0x628d('0x6f')],'as':_0x628d('0x9e'),'where':{'fax':_0x295977},'limit':0x1,'order':[['updatedAt','DESC']]}]}]})[_0x628d('0x1f')](handleEntityNotFound(_0x454f1a,null))['then'](function(_0x27b185){_0x116504=_0x27b185;if(_0x318590['body'][_0x628d('0x9f')]&&_0x318590[_0x628d('0x58')]['attachments']['length']){for(var _0x1c370d=0x0;_0x1c370d<_0x318590[_0x628d('0x58')]['attachments'][_0x628d('0x46')];_0x1c370d+=0x1){_0x318590['body']['attachments'][_0x1c370d]={'filename':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][_0x1c370d][_0x628d('0x37')],'id':_0x318590['body'][_0x628d('0x9f')][_0x1c370d]['id'],'path':path[_0x628d('0xa0')](config['root'],_0x628d('0xa1'),_0x318590[_0x628d('0x58')][_0x628d('0x9f')][_0x1c370d][_0x628d('0xa2')])};}}return respondWithRpcPromise(_0x628d('0xa3'),_0x628d('0xa3'),{'FaxAccountId':_[_0x628d('0xa4')](_0x318590[_0x628d('0x50')]['id'])?undefined:_0x318590[_0x628d('0x50')]['id'],'path':_[_0x628d('0xa4')](_0x318590[_0x628d('0x58')]['attachments'][0x0][_0x628d('0x8')])?undefined:_0x318590['body'][_0x628d('0x9f')][0x0][_0x628d('0x8')],'fax':_['isNil'](_0x318590['body']['to'][0x0])?undefined:_0x318590['body']['to'][0x0]},client9002);})[_0x628d('0x1f')](function(){if(_0x116504){if(_[_0x628d('0xa4')](_0x318590['body'][_0x628d('0xa5')])){_0x318590[_0x628d('0x58')][_0x628d('0xa5')]=util[_0x628d('0x9c')](_0x628d('0xa6'),_0x116504[_0x628d('0x37')],_0x116504[_0x628d('0xa7')]);}if(_0x116504[_0x628d('0x9d')]){if(_0x116504[_0x628d('0x9d')][_0x628d('0x9e')]['length']){return _0x116504[_0x628d('0x9d')]['Contacts'][0x0];}else{return db['CmContact']['create'](_[_0x628d('0x17')](_0x318590[_0x628d('0x58')],{'firstName':_0x318590['body']['to'][0x0],'phone':_0x318590[_0x628d('0x58')]['to'][0x0],'fax':_0x318590[_0x628d('0x58')]['to'][0x0],'ListId':_0x116504[_0x628d('0x96')]}));}}else{throw new Error('List\x20not\x20found');}}else{throw new Error(_0x628d('0xa8'));}})[_0x628d('0x1f')](function(_0x42edeb){if(_0x42edeb){return db[_0x628d('0x6b')]['find']({'where':{'ContactId':_0x42edeb['id'],'closed':![],'FaxAccountId':_0x116504['id']}})[_0x628d('0x1f')](function(_0x5d7514){if(_0x5d7514){return[_0x5d7514,![]];}return db['FaxInteraction'][_0x628d('0x52')]({'UserId':_0x318590[_0x628d('0x53')]['id'],'ContactId':_0x42edeb['id'],'FaxAccountId':_0x116504['id'],'fax':_0x318590['body']['to'][0x0],'firstMsgDirection':_0x628d('0xa9'),'Messages':[_[_0x628d('0x4c')](_0x318590['body'],{'read':![],'body':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0][_0x628d('0xaa')],'FaxAccountId':_0x116504['id'],'UserId':_0x318590[_0x628d('0x53')]['id'],'ContactId':_0x42edeb['id'],'AttachmentId':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0]['id']})]},{'include':[{'model':db[_0x628d('0x99')],'as':_0x628d('0xab')}]})[_0x628d('0x1f')](function(_0x541acb){return[_0x541acb,!![]];});});}else{throw new Error(_0x628d('0xac'));}})['spread'](function(_0x43d9b3,_0x13b125){if(_0x13b125){return _0x43d9b3;}return db[_0x628d('0x99')][_0x628d('0x52')]({'direction':'out','read':![],'body':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0]['filename'],'FaxAccountId':_0x116504['id'],'FaxInteractionId':_0x43d9b3['id'],'UserId':_0x318590[_0x628d('0x53')]['id'],'ContactId':_0x43d9b3[_0x628d('0xad')],'AttachmentId':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0]['id']})[_0x628d('0x1f')](function(_0x37d8fa){_0x43d9b3[_0x628d('0xae')]['Messages']=[];_0x43d9b3[_0x628d('0xae')][_0x628d('0xab')][_0x628d('0x8e')](_0x37d8fa['dataValues']);return _0x43d9b3;});})[_0x628d('0x1f')](function(_0x223ca1){respondWithRpcPromise(_0x628d('0xaf'),'SendFax',{'FaxAccountId':_['isNil'](_0x318590[_0x628d('0x50')]['id'])?undefined:_0x318590['params']['id'],'path':_[_0x628d('0xa4')](_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0][_0x628d('0x8')])?undefined:_0x318590['body'][_0x628d('0x9f')][0x0][_0x628d('0x8')],'fax':_[_0x628d('0xa4')](_0x318590[_0x628d('0x58')]['to'][0x0])?undefined:_0x318590['body']['to'][0x0],'AttachmentId':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0]['id']},client9002)[_0x628d('0x1f')](function(_0x1b9f4e){logger[_0x628d('0x20')]('SendFaxRpc,\x20%s',_0x1b9f4e);})[_0x628d('0x2a')](function(_0xee71bb){logger[_0x628d('0x20')](_0x628d('0xb0'),_0xee71bb);});return _0x223ca1;})['then'](respondWithResult(_0x454f1a,null))[_0x628d('0x2a')](handleError(_0x454f1a,null));};exports[_0x628d('0xb1')]=function(_0x2aac5b,_0x2225e8,_0x3110e7){return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x2aac5b[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x2225e8,null))['then'](function(_0xb80309){if(_0xb80309){return _0xb80309[_0x628d('0xb1')](_0x2aac5b[_0x628d('0x58')][_0x628d('0x65')],_['omit'](_0x2aac5b[_0x628d('0x58')],[_0x628d('0x65'),'id'])||{})['spread'](function(_0x1445af){for(var _0x1709e1=0x0;_0x1709e1<_0x2aac5b['body'][_0x628d('0x65')][_0x628d('0x46')];_0x1709e1+=0x1){socket[_0x628d('0xb2')]('userFaxAccount:save',{'UserId':_0x2aac5b['body'][_0x628d('0x65')][_0x1709e1],'FaxAccountId':_0x2aac5b[_0x628d('0x50')]['id']});}return _0x1445af;});}})[_0x628d('0x1f')](respondWithResult(_0x2225e8,null))[_0x628d('0x2a')](handleError(_0x2225e8,null));};exports[_0x628d('0xb3')]=function(_0x1e2430,_0xd6ca28,_0x5ac0ba){return db[_0x628d('0x3b')]['find']({'where':{'id':_0x1e2430[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0xd6ca28,null))[_0x628d('0x1f')](function(_0x2f5029){if(_0x2f5029){return _0x2f5029[_0x628d('0xb3')](_0x1e2430[_0x628d('0x41')][_0x628d('0x65')])[_0x628d('0x1f')](function(){if(_[_0x628d('0xb4')](_0x1e2430[_0x628d('0x41')][_0x628d('0x65')])){for(var _0x4cb9d1=0x0;_0x4cb9d1<_0x1e2430[_0x628d('0x41')][_0x628d('0x65')]['length'];_0x4cb9d1+=0x1){socket[_0x628d('0xb2')](_0x628d('0xb5'),{'UserId':Number(_0x1e2430[_0x628d('0x41')][_0x628d('0x65')][_0x4cb9d1]),'FaxAccountId':Number(_0x1e2430[_0x628d('0x50')]['id'])});}}else{socket[_0x628d('0xb2')](_0x628d('0xb5'),{'UserId':Number(_0x1e2430[_0x628d('0x41')][_0x628d('0x65')]),'FaxAccountId':Number(_0x1e2430[_0x628d('0x50')]['id'])});}});}})[_0x628d('0x1f')](respondWithStatusCode(_0xd6ca28,null))[_0x628d('0x2a')](handleError(_0xd6ca28,null));};exports['getAgents']=function(_0xc9b174,_0x3272fa,_0x9f4422){var _0x103a82={};var _0x2c4a1a={};var _0x51920a;var _0x36865a;return db[_0x628d('0x3b')][_0x628d('0x5f')]({'where':{'id':_0xc9b174[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x3272fa,null))[_0x628d('0x1f')](function(_0x3aef95){if(_0x3aef95){_0x51920a=_0x3aef95;_0x2c4a1a['model']=_[_0x628d('0x42')](db[_0x628d('0x71')]['rawAttributes']);_0x2c4a1a[_0x628d('0x41')]=_[_0x628d('0x42')](_0xc9b174['query']);_0x2c4a1a[_0x628d('0x4a')]=_['intersection'](_0x2c4a1a[_0x628d('0x40')],_0x2c4a1a[_0x628d('0x41')]);_0x103a82['attributes']=_[_0x628d('0x43')](_0x2c4a1a[_0x628d('0x40')],qs[_0x628d('0x45')](_0xc9b174[_0x628d('0x41')][_0x628d('0x45')]));_0x103a82[_0x628d('0x44')]=_0x103a82['attributes'][_0x628d('0x46')]?_0x103a82['attributes']:_0x2c4a1a['model'];_0x103a82['order']=qs[_0x628d('0x48')](_0xc9b174[_0x628d('0x41')][_0x628d('0x48')]);_0x103a82[_0x628d('0x49')]=qs[_0x628d('0x4a')](_[_0x628d('0x6e')](_0xc9b174[_0x628d('0x41')],_0x2c4a1a[_0x628d('0x4a')]));if(_0xc9b174[_0x628d('0x41')][_0x628d('0x4b')]){_0x103a82[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x103a82[_0x628d('0x49')],{'$or':_[_0x628d('0x3a')](_0x103a82['attributes'],function(_0x310e1d){var _0xbf2189={};_0xbf2189[_0x310e1d]={'$like':'%'+_0xc9b174[_0x628d('0x41')][_0x628d('0x4b')]+'%'};return _0xbf2189;})});}_0x103a82=_['merge']({},_0x103a82,_0xc9b174[_0x628d('0x4e')]);return _0x51920a[_0x628d('0xb6')](_0x103a82);}})['then'](function(_0x147902){if(_0x147902){_0x36865a=_0x147902['length'];if(!_0xc9b174[_0x628d('0x41')]['hasOwnProperty'](_0x628d('0x47'))){_0x103a82[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0xc9b174['query'][_0x628d('0x2f')]);_0x103a82[_0x628d('0x2e')]=qs[_0x628d('0x2e')](_0xc9b174[_0x628d('0x41')]['offset']);}return _0x51920a[_0x628d('0xb6')](_0x103a82);}})[_0x628d('0x1f')](function(_0x279003){if(_0x279003){return _0x279003?{'count':_0x36865a,'rows':_0x279003}:null;}})['then'](respondWithResult(_0x3272fa,null))['catch'](handleError(_0x3272fa,null));};
\ No newline at end of file