Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index 16496dd..dac55f4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4de4=['ISOLATION_LEVELS','READ_COMMITTED','FaxApplication','findAndCountAll','finally','send','getApplications','context','from-voip-provider','exten','localstationid','app','system','description','Fax\x20Extension','priority','appdata','push','Set','ecm','headerinfo','maxrate','t38timeout','FAXOPT(','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','ReceiveFax','addAccountApplications','VoiceExtension','bulkCreate','updateAccountApplications','tech','createdAt','updatedAt','TrunkId','ListId','findById','getMessages','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','FaxMessage','CmList','List','CmContact','Contacts','DESC','attachments','join','root','basename','CheckAfterSend','isNil','from','fax','List\x20not\x20found','out','filename','Messages','Contact\x20not\x20found','spread','ContactId','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','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxAccount.socket','register','jayson/promise','client','http','request','info','FaxAccount,\x20%s,\x20%s','request\x20sent','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','sendStatus','end','offset','limit','undefined','count','status','set','Content-Range','json','apply','update','then','get','FaxAccounts','UserProfileResource','destroy','stack','name','index','mandatoryDispositionPause','rawAttributes','fieldName','type','key','model','map','keys','query','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','merge','VIRTUAL','filter','FaxAccount','includeAll','include','findAll','Pause','length','options','find','create','body','role','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','FaxAccountId','Disposition','getDispositions','findOne','pick','rows','removeDispositions','ids','addAnswer','getAnswers','CannedAnswer','removeAnswers','addInteraction','FaxInteraction','omit','getInteractions','Owner','fullname','internal','Tag','Tags','tag','sequelize','transaction','Transaction'];(function(_0x237052,_0x28636d){var _0x627e37=function(_0x4686c9){while(--_0x4686c9){_0x237052['push'](_0x237052['shift']());}};_0x627e37(++_0x28636d);}(_0x4de4,0x1e1));var _0x44de=function(_0x3f0ce6,_0xb507c3){_0x3f0ce6=_0x3f0ce6-0x0;var _0x4ee207=_0x4de4[_0x3f0ce6];return _0x4ee207;};'use strict';var emlformat=require(_0x44de('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x44de('0x1'));var jsonpatch=require(_0x44de('0x2'));var rp=require(_0x44de('0x3'));var moment=require(_0x44de('0x4'));var BPromise=require(_0x44de('0x5'));var Mustache=require(_0x44de('0x6'));var util=require('util');var path=require(_0x44de('0x7'));var sox=require(_0x44de('0x8'));var csv=require(_0x44de('0x9'));var ejs=require(_0x44de('0xa'));var fs=require('fs');var fs_extra=require(_0x44de('0xb'));var _=require(_0x44de('0xc'));var squel=require(_0x44de('0xd'));var crypto=require(_0x44de('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x44de('0xf'));var toCsv=require(_0x44de('0x9'));var querystring=require(_0x44de('0x10'));var Papa=require(_0x44de('0x11'));var Redis=require(_0x44de('0x12'));var authService=require(_0x44de('0x13'));var qs=require(_0x44de('0x14'));var as=require(_0x44de('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x44de('0x16'))(_0x44de('0x17'));var utils=require('../../config/utils');var config=require(_0x44de('0x18'));var licenseUtil=require(_0x44de('0x19'));var db=require(_0x44de('0x1a'))['db'];config['redis']=_['defaults'](config[_0x44de('0x1b')],{'host':_0x44de('0x1c'),'port':0x18eb});var socket=require(_0x44de('0x1d'))(new Redis(config['redis']));require(_0x44de('0x1e'))[_0x44de('0x1f')](socket);var jayson=require(_0x44de('0x20'));var client=jayson[_0x44de('0x21')][_0x44de('0x22')]({'port':0x232c});var client9002=jayson['client'][_0x44de('0x22')]({'port':0x232a});function respondWithRpcPromise(_0x21327e,_0x104c6e,_0x4c72ce,_0x5961a2){return new BPromise(function(_0x51e728,_0x547a61){var _0x14bb7b=_0x5961a2||client;return _0x14bb7b[_0x44de('0x23')](_0x21327e,_0x4c72ce)['then'](function(_0x9aa01e){logger[_0x44de('0x24')](_0x44de('0x25'),_0x104c6e,_0x44de('0x26'));logger['debug'](_0x44de('0x27'),_0x104c6e,_0x44de('0x26'),JSON[_0x44de('0x28')](_0x9aa01e));if(_0x9aa01e['error']){if(_0x9aa01e['error'][_0x44de('0x29')]===0x1f4){logger['error'](_0x44de('0x25'),_0x104c6e,_0x9aa01e[_0x44de('0x2a')][_0x44de('0x2b')]);return _0x547a61(_0x9aa01e['error']['message']);}logger['error']('FaxAccount,\x20%s,\x20%s',_0x104c6e,_0x9aa01e[_0x44de('0x2a')][_0x44de('0x2b')]);return _0x51e728(_0x9aa01e['error'][_0x44de('0x2b')]);}else{logger['info'](_0x44de('0x25'),_0x104c6e,_0x44de('0x26'));_0x51e728(_0x9aa01e[_0x44de('0x2c')][_0x44de('0x2b')]);}})[_0x44de('0x2d')](function(_0x390f82){logger['error']('FaxAccount,\x20%s,\x20%s',_0x104c6e,_0x390f82);_0x547a61(_0x390f82);});});}function respondWithStatusCode(_0x1c4f62,_0x759798){_0x759798=_0x759798||0xcc;return function(_0x1c36a6){if(_0x1c36a6){return _0x1c4f62[_0x44de('0x2e')](_0x759798);}return _0x1c4f62['status'](_0x759798)[_0x44de('0x2f')]();};}function respondWithResult(_0x349f1b,_0x5c8430){_0x5c8430=_0x5c8430||0xc8;return function(_0x3b93b9){if(_0x3b93b9){return _0x349f1b['status'](_0x5c8430)['json'](_0x3b93b9);}};}function respondWithFilteredResult(_0x41e044,_0x4fdd17){return function(_0x2a5148){if(_0x2a5148){var _0x410744=typeof _0x4fdd17[_0x44de('0x30')]==='undefined'&&typeof _0x4fdd17[_0x44de('0x31')]===_0x44de('0x32');var _0x156715=_0x2a5148['count'];var _0x396b43=_0x410744?0x0:_0x4fdd17['offset'];var _0x37ec93=_0x410744?_0x2a5148[_0x44de('0x33')]:_0x4fdd17[_0x44de('0x30')]+_0x4fdd17[_0x44de('0x31')];var _0x1e3719;if(_0x37ec93>=_0x156715){_0x37ec93=_0x156715;_0x1e3719=0xc8;}else{_0x1e3719=0xce;}_0x41e044[_0x44de('0x34')](_0x1e3719);return _0x41e044[_0x44de('0x35')](_0x44de('0x36'),_0x396b43+'-'+_0x37ec93+'/'+_0x156715)[_0x44de('0x37')](_0x2a5148);}return null;};}function patchUpdates(_0x4bf7ec){return function(_0x20b734){try{jsonpatch[_0x44de('0x38')](_0x20b734,_0x4bf7ec,!![]);}catch(_0x99013f){return BPromise['reject'](_0x99013f);}return _0x20b734['save']();};}function saveUpdates(_0xaadf4d,_0x47b9f2){return function(_0x2f2ee9){if(_0x2f2ee9){return _0x2f2ee9[_0x44de('0x39')](_0xaadf4d)[_0x44de('0x3a')](function(_0x44b6e7){return _0x44b6e7;});}return null;};}function removeEntity(_0x243f66,_0x476284){return function(_0x40a45a){if(_0x40a45a){return _0x40a45a['destroy']()['then'](function(){var _0x570a84=_0x40a45a[_0x44de('0x3b')]({'plain':!![]});var _0x5c2c4c=_0x44de('0x3c');return db[_0x44de('0x3d')][_0x44de('0x3e')]({'where':{'type':_0x5c2c4c,'resourceId':_0x570a84['id']}})[_0x44de('0x3a')](function(){return _0x40a45a;});})['then'](function(){_0x243f66['status'](0xcc)[_0x44de('0x2f')]();});}};}function handleEntityNotFound(_0x5e5a96,_0x313670){return function(_0x3f64f6){if(!_0x3f64f6){_0x5e5a96[_0x44de('0x2e')](0x194);}return _0x3f64f6;};}function handleError(_0x408a27,_0x543574){_0x543574=_0x543574||0x1f4;return function(_0x81d41a){logger[_0x44de('0x2a')](_0x81d41a[_0x44de('0x3f')]);if(_0x81d41a['name']){delete _0x81d41a[_0x44de('0x40')];}_0x408a27['status'](_0x543574)['send'](_0x81d41a);};}exports[_0x44de('0x41')]=function(_0x429564,_0x2d0585){var _0x2236f2={'include':[{'model':db['Pause'],'as':_0x44de('0x42')}]},_0x1d76ce={},_0x446d91={'count':0x0,'rows':[]};var _0x2a78ee=_['map'](db['FaxAccount'][_0x44de('0x43')],function(_0x1a8486){return{'name':_0x1a8486[_0x44de('0x44')],'type':_0x1a8486[_0x44de('0x45')][_0x44de('0x46')]};});_0x1d76ce[_0x44de('0x47')]=_[_0x44de('0x48')](_0x2a78ee,_0x44de('0x40'));_0x1d76ce['query']=_[_0x44de('0x49')](_0x429564[_0x44de('0x4a')]);_0x1d76ce[_0x44de('0x4b')]=_[_0x44de('0x4c')](_0x1d76ce['model'],_0x1d76ce[_0x44de('0x4a')]);_0x2236f2['attributes']=_[_0x44de('0x4c')](_0x1d76ce[_0x44de('0x47')],qs[_0x44de('0x4d')](_0x429564[_0x44de('0x4a')][_0x44de('0x4d')]));_0x2236f2[_0x44de('0x4e')]=_0x2236f2[_0x44de('0x4e')]['length']?_0x2236f2[_0x44de('0x4e')]:_0x1d76ce[_0x44de('0x47')];if(!_0x429564[_0x44de('0x4a')][_0x44de('0x4f')](_0x44de('0x50'))){_0x2236f2[_0x44de('0x31')]=qs['limit'](_0x429564[_0x44de('0x4a')][_0x44de('0x31')]);_0x2236f2[_0x44de('0x30')]=qs[_0x44de('0x30')](_0x429564[_0x44de('0x4a')]['offset']);}_0x2236f2[_0x44de('0x51')]=qs[_0x44de('0x52')](_0x429564[_0x44de('0x4a')][_0x44de('0x52')]);_0x2236f2[_0x44de('0x53')]=qs['filters'](_['pick'](_0x429564[_0x44de('0x4a')],_0x1d76ce[_0x44de('0x4b')]),_0x2a78ee);if(_0x429564[_0x44de('0x4a')]['filter']){_0x2236f2['where']=_[_0x44de('0x54')](_0x2236f2[_0x44de('0x53')],{'$or':_['map'](_0x2a78ee,function(_0x122311){if(_0x122311[_0x44de('0x45')]!==_0x44de('0x55')){var _0x4d4e97={};_0x4d4e97[_0x122311[_0x44de('0x40')]]={'$like':'%'+_0x429564[_0x44de('0x4a')][_0x44de('0x56')]+'%'};return _0x4d4e97;}})});}_0x2236f2=_[_0x44de('0x54')]({},_0x2236f2,_0x429564['options']);var _0x3f4ae0={'where':_0x2236f2[_0x44de('0x53')]};return db[_0x44de('0x57')][_0x44de('0x33')](_0x3f4ae0)['then'](function(_0x21012a){_0x446d91[_0x44de('0x33')]=_0x21012a;if(_0x429564[_0x44de('0x4a')][_0x44de('0x58')]){_0x2236f2[_0x44de('0x59')]=[{'all':!![]}];}return db['FaxAccount'][_0x44de('0x5a')](_0x2236f2);})[_0x44de('0x3a')](function(_0x9a51a2){_0x446d91['rows']=_0x9a51a2;return _0x446d91;})[_0x44de('0x3a')](respondWithFilteredResult(_0x2d0585,_0x2236f2))[_0x44de('0x2d')](handleError(_0x2d0585,null));};exports['show']=function(_0x1d0e7c,_0x20b371){var _0x479e7a={'raw':![],'where':{'id':_0x1d0e7c['params']['id']},'include':[{'model':db[_0x44de('0x5b')],'as':'mandatoryDispositionPause'}]},_0x181344={};_0x181344['model']=_[_0x44de('0x49')](db[_0x44de('0x57')][_0x44de('0x43')]);_0x181344[_0x44de('0x4a')]=_[_0x44de('0x49')](_0x1d0e7c[_0x44de('0x4a')]);_0x181344[_0x44de('0x4b')]=_[_0x44de('0x4c')](_0x181344[_0x44de('0x47')],_0x181344[_0x44de('0x4a')]);_0x479e7a['attributes']=_[_0x44de('0x4c')](_0x181344[_0x44de('0x47')],qs[_0x44de('0x4d')](_0x1d0e7c['query'][_0x44de('0x4d')]));_0x479e7a[_0x44de('0x4e')]=_0x479e7a[_0x44de('0x4e')][_0x44de('0x5c')]?_0x479e7a['attributes']:_0x181344[_0x44de('0x47')];if(_0x1d0e7c[_0x44de('0x4a')]['includeAll']){_0x479e7a[_0x44de('0x59')]=[{'all':!![]}];}_0x479e7a=_[_0x44de('0x54')]({},_0x479e7a,_0x1d0e7c[_0x44de('0x5d')]);return db[_0x44de('0x57')][_0x44de('0x5e')](_0x479e7a)['then'](handleEntityNotFound(_0x20b371,null))['then'](respondWithResult(_0x20b371,null))['catch'](handleError(_0x20b371,null));};exports[_0x44de('0x5f')]=function(_0x25ed2c,_0x432038){return db['FaxAccount']['create'](_0x25ed2c[_0x44de('0x60')],{})[_0x44de('0x3a')](function(_0x34adc9){var _0x1c7ab4=_0x25ed2c['user'][_0x44de('0x3b')]({'plain':!![]});if(!_0x1c7ab4)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1c7ab4[_0x44de('0x61')]===_0x44de('0x62')){var _0x85f19e=_0x34adc9[_0x44de('0x3b')]({'plain':!![]});var _0x5436b9=_0x44de('0x3c');return db[_0x44de('0x63')][_0x44de('0x5e')]({'where':{'name':_0x5436b9,'userProfileId':_0x1c7ab4[_0x44de('0x64')]},'raw':!![]})[_0x44de('0x3a')](function(_0x235649){if(_0x235649&&_0x235649[_0x44de('0x65')]===0x0){return db['UserProfileResource']['create']({'name':_0x85f19e['name'],'resourceId':_0x85f19e['id'],'type':_0x235649[_0x44de('0x40')],'sectionId':_0x235649['id']},{})[_0x44de('0x3a')](function(){return _0x34adc9;});}else{return _0x34adc9;}})[_0x44de('0x2d')](function(_0x5b4054){logger[_0x44de('0x2a')](_0x44de('0x66'),_0x5b4054);throw _0x5b4054;});}return _0x34adc9;})['then'](respondWithResult(_0x432038,0xc9))[_0x44de('0x2d')](handleError(_0x432038,null));};exports[_0x44de('0x39')]=function(_0x53de1f,_0x22a9ba){if(_0x53de1f[_0x44de('0x60')]['id']){delete _0x53de1f[_0x44de('0x60')]['id'];}return db[_0x44de('0x57')][_0x44de('0x5e')]({'where':{'id':_0x53de1f[_0x44de('0x67')]['id']},'include':[{'model':db['Pause'],'as':_0x44de('0x42')}]})['then'](handleEntityNotFound(_0x22a9ba,null))[_0x44de('0x3a')](saveUpdates(_0x53de1f[_0x44de('0x60')],null))[_0x44de('0x3a')](respondWithResult(_0x22a9ba,null))['catch'](handleError(_0x22a9ba,null));};exports[_0x44de('0x3e')]=function(_0x104c3c,_0x12c551){return db[_0x44de('0x57')][_0x44de('0x5e')]({'where':{'id':_0x104c3c[_0x44de('0x67')]['id']}})[_0x44de('0x3a')](handleEntityNotFound(_0x12c551,null))[_0x44de('0x3a')](removeEntity(_0x12c551,null))['catch'](handleError(_0x12c551,null));};exports[_0x44de('0x68')]=function(_0x4219a7,_0x38b20e){return db[_0x44de('0x57')][_0x44de('0x68')]()[_0x44de('0x3a')](respondWithResult(_0x38b20e,null))[_0x44de('0x2d')](handleError(_0x38b20e,null));};exports[_0x44de('0x69')]=function(_0x36c187,_0x5c0068,_0x191282){if(_0x36c187['body']['id']){delete _0x36c187[_0x44de('0x60')]['id'];}return db[_0x44de('0x57')][_0x44de('0x5e')]({'where':{'id':_0x36c187[_0x44de('0x67')]['id']}})['then'](handleEntityNotFound(_0x5c0068,null))[_0x44de('0x3a')](function(_0x11ef64){if(_0x11ef64){_0x36c187[_0x44de('0x60')][_0x44de('0x6a')]=_0x11ef64['id'];return db[_0x44de('0x6b')][_0x44de('0x5f')](_0x36c187['body']);}})[_0x44de('0x3a')](respondWithResult(_0x5c0068,null))[_0x44de('0x2d')](handleError(_0x5c0068,null));};exports[_0x44de('0x6c')]=function(_0x2d28e0,_0xbfb573,_0x5428ef){var _0x4c0045={'raw':![],'where':{}};var _0x4a7a28={};var _0x44f99f={'count':0x0,'rows':[]};return db['FaxAccount'][_0x44de('0x6d')]({'where':{'id':_0x2d28e0[_0x44de('0x67')]['id']}})['then'](handleEntityNotFound(_0xbfb573,null))[_0x44de('0x3a')](function(_0x5acadc){if(_0x5acadc){_0x4a7a28[_0x44de('0x47')]=_[_0x44de('0x49')](db[_0x44de('0x6b')][_0x44de('0x43')]);_0x4a7a28[_0x44de('0x4a')]=_[_0x44de('0x49')](_0x2d28e0[_0x44de('0x4a')]);_0x4a7a28['filters']=_[_0x44de('0x4c')](_0x4a7a28[_0x44de('0x47')],_0x4a7a28[_0x44de('0x4a')]);_0x4c0045[_0x44de('0x4e')]=_[_0x44de('0x4c')](_0x4a7a28[_0x44de('0x47')],qs[_0x44de('0x4d')](_0x2d28e0[_0x44de('0x4a')][_0x44de('0x4d')]));_0x4c0045[_0x44de('0x4e')]=_0x4c0045['attributes'][_0x44de('0x5c')]?_0x4c0045[_0x44de('0x4e')]:_0x4a7a28[_0x44de('0x47')];if(!_0x2d28e0[_0x44de('0x4a')][_0x44de('0x4f')](_0x44de('0x50'))){_0x4c0045[_0x44de('0x31')]=qs[_0x44de('0x31')](_0x2d28e0['query'][_0x44de('0x31')]);_0x4c0045[_0x44de('0x30')]=qs[_0x44de('0x30')](_0x2d28e0[_0x44de('0x4a')][_0x44de('0x30')]);}_0x4c0045[_0x44de('0x51')]=qs[_0x44de('0x52')](_0x2d28e0['query']['sort']);_0x4c0045[_0x44de('0x53')]=qs[_0x44de('0x4b')](_[_0x44de('0x6e')](_0x2d28e0[_0x44de('0x4a')],_0x4a7a28['filters']));_0x4c0045['where'][_0x44de('0x6a')]=_0x5acadc['id'];if(_0x2d28e0['query']['filter']){_0x4c0045[_0x44de('0x53')]=_[_0x44de('0x54')](_0x4c0045[_0x44de('0x53')],{'$or':_[_0x44de('0x48')](_0x4c0045[_0x44de('0x4e')],function(_0x2e7127){var _0x2dd1b6={};_0x2dd1b6[_0x2e7127]={'$like':'%'+_0x2d28e0[_0x44de('0x4a')][_0x44de('0x56')]+'%'};return _0x2dd1b6;})});}_0x4c0045=_[_0x44de('0x54')]({},_0x4c0045,_0x2d28e0['options']);return db['Disposition'][_0x44de('0x33')]({'where':_0x4c0045[_0x44de('0x53')]})['then'](function(_0x3e9127){_0x44f99f[_0x44de('0x33')]=_0x3e9127;if(_0x2d28e0[_0x44de('0x4a')]['includeAll']){_0x4c0045['include']=[{'all':!![]}];}return db['Disposition'][_0x44de('0x5a')](_0x4c0045);})[_0x44de('0x3a')](function(_0x275813){_0x44f99f[_0x44de('0x6f')]=_0x275813;return _0x44f99f;});}})[_0x44de('0x3a')](respondWithFilteredResult(_0xbfb573,_0x4c0045))[_0x44de('0x2d')](handleError(_0xbfb573,null));};exports[_0x44de('0x70')]=function(_0x272aa5,_0x45ddc9,_0x52f614){return db[_0x44de('0x57')][_0x44de('0x5e')]({'where':{'id':_0x272aa5[_0x44de('0x67')]['id']}})['then'](handleEntityNotFound(_0x45ddc9,null))[_0x44de('0x3a')](function(_0x3173a6){if(_0x3173a6){return _0x3173a6[_0x44de('0x70')](_0x272aa5[_0x44de('0x4a')][_0x44de('0x71')]);}})[_0x44de('0x3a')](respondWithStatusCode(_0x45ddc9,null))[_0x44de('0x2d')](handleError(_0x45ddc9,null));};exports[_0x44de('0x72')]=function(_0x65f0e2,_0x54fa6c,_0x254877){if(_0x65f0e2[_0x44de('0x60')]['id']){delete _0x65f0e2[_0x44de('0x60')]['id'];}return db[_0x44de('0x57')][_0x44de('0x5e')]({'where':{'id':_0x65f0e2[_0x44de('0x67')]['id']}})['then'](handleEntityNotFound(_0x54fa6c,null))[_0x44de('0x3a')](function(_0x1120d1){if(_0x1120d1){_0x65f0e2[_0x44de('0x60')][_0x44de('0x6a')]=_0x1120d1['id'];return db['CannedAnswer'][_0x44de('0x5f')](_0x65f0e2[_0x44de('0x60')]);}})[_0x44de('0x3a')](respondWithResult(_0x54fa6c,null))['catch'](handleError(_0x54fa6c,null));};exports[_0x44de('0x73')]=function(_0x1be851,_0x23a8a8,_0x3ad308){var _0x362c66={'raw':![],'where':{}};var _0x41278d={};var _0x305e16={'count':0x0,'rows':[]};return db[_0x44de('0x57')][_0x44de('0x6d')]({'where':{'id':_0x1be851['params']['id']}})['then'](handleEntityNotFound(_0x23a8a8,null))[_0x44de('0x3a')](function(_0x5b9bcd){if(_0x5b9bcd){_0x41278d['model']=_[_0x44de('0x49')](db[_0x44de('0x74')]['rawAttributes']);_0x41278d[_0x44de('0x4a')]=_[_0x44de('0x49')](_0x1be851['query']);_0x41278d[_0x44de('0x4b')]=_[_0x44de('0x4c')](_0x41278d[_0x44de('0x47')],_0x41278d[_0x44de('0x4a')]);_0x362c66['attributes']=_[_0x44de('0x4c')](_0x41278d[_0x44de('0x47')],qs[_0x44de('0x4d')](_0x1be851[_0x44de('0x4a')][_0x44de('0x4d')]));_0x362c66[_0x44de('0x4e')]=_0x362c66[_0x44de('0x4e')][_0x44de('0x5c')]?_0x362c66[_0x44de('0x4e')]:_0x41278d[_0x44de('0x47')];if(!_0x1be851[_0x44de('0x4a')][_0x44de('0x4f')](_0x44de('0x50'))){_0x362c66[_0x44de('0x31')]=qs[_0x44de('0x31')](_0x1be851['query'][_0x44de('0x31')]);_0x362c66[_0x44de('0x30')]=qs[_0x44de('0x30')](_0x1be851['query'][_0x44de('0x30')]);}_0x362c66['order']=qs[_0x44de('0x52')](_0x1be851[_0x44de('0x4a')][_0x44de('0x52')]);_0x362c66[_0x44de('0x53')]=qs[_0x44de('0x4b')](_[_0x44de('0x6e')](_0x1be851[_0x44de('0x4a')],_0x41278d[_0x44de('0x4b')]));_0x362c66[_0x44de('0x53')][_0x44de('0x6a')]=_0x5b9bcd['id'];if(_0x1be851[_0x44de('0x4a')][_0x44de('0x56')]){_0x362c66[_0x44de('0x53')]=_[_0x44de('0x54')](_0x362c66[_0x44de('0x53')],{'$or':_[_0x44de('0x48')](_0x362c66[_0x44de('0x4e')],function(_0x1e5aad){var _0x1d99c4={};_0x1d99c4[_0x1e5aad]={'$like':'%'+_0x1be851[_0x44de('0x4a')][_0x44de('0x56')]+'%'};return _0x1d99c4;})});}_0x362c66=_['merge']({},_0x362c66,_0x1be851[_0x44de('0x5d')]);return db[_0x44de('0x74')][_0x44de('0x33')]({'where':_0x362c66['where']})[_0x44de('0x3a')](function(_0x4d4d68){_0x305e16[_0x44de('0x33')]=_0x4d4d68;if(_0x1be851[_0x44de('0x4a')][_0x44de('0x58')]){_0x362c66['include']=[{'all':!![]}];}return db['CannedAnswer']['findAll'](_0x362c66);})[_0x44de('0x3a')](function(_0x396e15){_0x305e16['rows']=_0x396e15;return _0x305e16;});}})[_0x44de('0x3a')](respondWithFilteredResult(_0x23a8a8,_0x362c66))[_0x44de('0x2d')](handleError(_0x23a8a8,null));};exports[_0x44de('0x75')]=function(_0x5a47f,_0x2f3fed,_0x26fb83){return db[_0x44de('0x57')]['find']({'where':{'id':_0x5a47f[_0x44de('0x67')]['id']}})['then'](handleEntityNotFound(_0x2f3fed,null))[_0x44de('0x3a')](function(_0x32192b){if(_0x32192b){return _0x32192b['removeAnswers'](_0x5a47f[_0x44de('0x4a')][_0x44de('0x71')]);}})['then'](respondWithStatusCode(_0x2f3fed,null))[_0x44de('0x2d')](handleError(_0x2f3fed,null));};exports[_0x44de('0x76')]=function(_0x39744c,_0x344ad5,_0x287f1e){return db[_0x44de('0x77')][_0x44de('0x5e')]({'where':{'id':_0x39744c['params']['id']}})['then'](handleEntityNotFound(_0x344ad5,null))[_0x44de('0x3a')](function(_0x52cc3c){if(_0x52cc3c){return _0x52cc3c[_0x44de('0x76')](_0x39744c[_0x44de('0x60')][_0x44de('0x71')],_[_0x44de('0x78')](_0x39744c[_0x44de('0x60')],[_0x44de('0x71'),'id'])||{});}})[_0x44de('0x3a')](respondWithResult(_0x344ad5,null))[_0x44de('0x2d')](handleError(_0x344ad5,null));};exports[_0x44de('0x79')]=function(_0x5033ce,_0x5067b4,_0x5dbc2b){var _0x2107a2={'raw':![],'where':{}};var _0x491d00={};var _0x3de5b7={'count':0x0,'rows':[]};return db[_0x44de('0x57')][_0x44de('0x6d')]({'where':{'id':_0x5033ce[_0x44de('0x67')]['id']}})[_0x44de('0x3a')](handleEntityNotFound(_0x5067b4,null))[_0x44de('0x3a')](function(_0x2017f5){if(_0x2017f5){_0x491d00[_0x44de('0x47')]=_[_0x44de('0x49')](db['FaxInteraction'][_0x44de('0x43')]);_0x491d00['query']=_[_0x44de('0x49')](_0x5033ce['query']);_0x491d00[_0x44de('0x4b')]=_[_0x44de('0x4c')](_0x491d00['model'],_0x491d00[_0x44de('0x4a')]);_0x2107a2['attributes']=_[_0x44de('0x4c')](_0x491d00['model'],qs[_0x44de('0x4d')](_0x5033ce[_0x44de('0x4a')][_0x44de('0x4d')]));_0x2107a2['attributes']=_0x2107a2[_0x44de('0x4e')]['length']?_0x2107a2[_0x44de('0x4e')]:_0x491d00['model'];if(!_0x5033ce['query'][_0x44de('0x4f')]('nolimit')){_0x2107a2[_0x44de('0x31')]=qs[_0x44de('0x31')](_0x5033ce[_0x44de('0x4a')][_0x44de('0x31')]);_0x2107a2[_0x44de('0x30')]=qs['offset'](_0x5033ce[_0x44de('0x4a')][_0x44de('0x30')]);}_0x2107a2[_0x44de('0x51')]=qs[_0x44de('0x52')](_0x5033ce[_0x44de('0x4a')][_0x44de('0x52')]);_0x2107a2['where']=qs['filters'](_[_0x44de('0x6e')](_0x5033ce[_0x44de('0x4a')],_0x491d00[_0x44de('0x4b')]));_0x2107a2['where'][_0x44de('0x6a')]=_0x2017f5['id'];if(_0x5033ce[_0x44de('0x4a')][_0x44de('0x56')]){_0x2107a2['where']=_[_0x44de('0x54')](_0x2107a2[_0x44de('0x53')],{'$or':_['map'](_0x2107a2['attributes'],function(_0x500449){var _0x2fc594={};_0x2fc594[_0x500449]={'$like':'%'+_0x5033ce['query'][_0x44de('0x56')]+'%'};return _0x2fc594;})});}_0x2107a2=_[_0x44de('0x54')]({},_0x2107a2,_0x5033ce['options']);return db['FaxInteraction'][_0x44de('0x33')]({'where':_0x2107a2['where']})['then'](function(_0x5650e9){_0x3de5b7[_0x44de('0x33')]=_0x5650e9;if(_0x5033ce[_0x44de('0x4a')]['includeAll']){_0x2107a2[_0x44de('0x59')]=[{'model':db['CmContact'],'as':'Contact','required':![]},{'model':db['User'],'as':_0x44de('0x7a'),'attributes':['name',_0x44de('0x7b'),_0x44de('0x7c')],'required':![]},{'model':db[_0x44de('0x7d')],'as':_0x44de('0x7e'),'attributes':['id',_0x44de('0x40'),'color'],'where':_0x5033ce[_0x44de('0x4a')][_0x44de('0x7f')]?{'id':_0x5033ce['query'][_0x44de('0x7f')]}:undefined,'required':_0x5033ce[_0x44de('0x4a')]['tag']?!![]:![]}];}return db[_0x44de('0x77')][_0x44de('0x5a')](_0x2107a2);})[_0x44de('0x3a')](function(_0xcad592){_0x3de5b7[_0x44de('0x6f')]=_0xcad592;return _0x3de5b7;});}})[_0x44de('0x3a')](respondWithFilteredResult(_0x5067b4,_0x2107a2))[_0x44de('0x2d')](handleError(_0x5067b4,null));};exports['addApplications']=function(_0x227d89,_0x4687cf){var _0x7325b2=_0x227d89['params']['id'];var _0x569f95=_0x227d89[_0x44de('0x60')];var _0x1a04fc=0xc8;var _0x4639aa=null;return db[_0x44de('0x80')][_0x44de('0x81')]({'isolationLevel':db['sequelize'][_0x44de('0x82')][_0x44de('0x83')][_0x44de('0x84')]},function(_0x92ff7f){return db[_0x44de('0x57')][_0x44de('0x6d')]({'where':{'id':_0x7325b2},'transaction':_0x92ff7f})[_0x44de('0x3a')](function(_0x3f3a3c){if(_0x3f3a3c){return db[_0x44de('0x85')][_0x44de('0x3e')]({'where':{'FaxAccountId':_0x7325b2},'transaction':_0x92ff7f})['then'](function(){var _0x2e236c=_[_0x44de('0x48')](_0x569f95,function(_0x20549e){_0x20549e['FaxAccountId']=_0x7325b2;return _0x20549e;});return db[_0x44de('0x85')]['bulkCreate'](_0x2e236c,{'transaction':_0x92ff7f});});}else{_0x1a04fc=0x194;_0x4639aa=[];}});})['then'](function(){if(_0x1a04fc!==0x194){return db[_0x44de('0x85')][_0x44de('0x86')]({'where':{'FaxAccountId':_0x7325b2},'order':'priority'})[_0x44de('0x3a')](function(_0x4218fb){_0x4639aa=_0x4218fb;});}})['catch'](function(_0x12eb8c){_0x1a04fc=0x1f4;logger[_0x44de('0x2a')](_0x12eb8c[_0x44de('0x3f')]);if(_0x12eb8c[_0x44de('0x40')]){delete _0x12eb8c[_0x44de('0x40')];}_0x4639aa=_0x12eb8c;})[_0x44de('0x87')](function(){if(_0x4639aa===null){_0x4687cf[_0x44de('0x2e')](_0x1a04fc);}else{if(_0x1a04fc===0x1f4){_0x4687cf[_0x44de('0x34')](_0x1a04fc)[_0x44de('0x88')](_0x4639aa);}else{_0x4687cf['status'](_0x1a04fc)[_0x44de('0x37')](_0x4639aa);}}});};exports['getApplications']=function(_0x59aa7d,_0x3ac3cf,_0x511e0a){var _0x2f66b2={};var _0x4e5c74={};var _0x16c60f;var _0x269586;return db[_0x44de('0x57')][_0x44de('0x6d')]({'where':{'id':_0x59aa7d[_0x44de('0x67')]['id']}})[_0x44de('0x3a')](handleEntityNotFound(_0x3ac3cf,null))[_0x44de('0x3a')](function(_0x24bcd0){if(_0x24bcd0){_0x16c60f=_0x24bcd0;_0x4e5c74[_0x44de('0x47')]=_['keys'](db[_0x44de('0x85')][_0x44de('0x43')]);_0x4e5c74['query']=_['keys'](_0x59aa7d[_0x44de('0x4a')]);_0x4e5c74[_0x44de('0x4b')]=_[_0x44de('0x4c')](_0x4e5c74[_0x44de('0x47')],_0x4e5c74[_0x44de('0x4a')]);_0x2f66b2[_0x44de('0x4e')]=_[_0x44de('0x4c')](_0x4e5c74[_0x44de('0x47')],qs[_0x44de('0x4d')](_0x59aa7d[_0x44de('0x4a')][_0x44de('0x4d')]));_0x2f66b2['attributes']=_0x2f66b2[_0x44de('0x4e')][_0x44de('0x5c')]?_0x2f66b2[_0x44de('0x4e')]:_0x4e5c74[_0x44de('0x47')];_0x2f66b2['order']=qs[_0x44de('0x52')](_0x59aa7d['query'][_0x44de('0x52')]);_0x2f66b2['where']=qs['filters'](_['pick'](_0x59aa7d[_0x44de('0x4a')],_0x4e5c74[_0x44de('0x4b')]));if(_0x59aa7d[_0x44de('0x4a')][_0x44de('0x56')]){_0x2f66b2['where']=_[_0x44de('0x54')](_0x2f66b2[_0x44de('0x53')],{'$or':_['map'](_0x2f66b2[_0x44de('0x4e')],function(_0x1f5687){var _0x31f769={};_0x31f769[_0x1f5687]={'$like':'%'+_0x59aa7d[_0x44de('0x4a')][_0x44de('0x56')]+'%'};return _0x31f769;})});}_0x2f66b2=_[_0x44de('0x54')]({},_0x2f66b2,_0x59aa7d[_0x44de('0x5d')]);return _0x16c60f['getApplications'](_0x2f66b2);}})[_0x44de('0x3a')](function(_0x4752cb){if(_0x4752cb){_0x269586=_0x4752cb[_0x44de('0x5c')];if(!_0x59aa7d['query'][_0x44de('0x4f')](_0x44de('0x50'))){_0x2f66b2['limit']=qs[_0x44de('0x31')](_0x59aa7d[_0x44de('0x4a')][_0x44de('0x31')]);_0x2f66b2['offset']=qs[_0x44de('0x30')](_0x59aa7d[_0x44de('0x4a')][_0x44de('0x30')]);}return _0x16c60f[_0x44de('0x89')](_0x2f66b2);}})[_0x44de('0x3a')](function(_0x1b7e4a){if(_0x1b7e4a){return _0x1b7e4a?{'count':_0x269586,'rows':_0x1b7e4a}:null;}})[_0x44de('0x3a')](respondWithResult(_0x3ac3cf,null))[_0x44de('0x2d')](handleError(_0x3ac3cf,null));};function Extension(_0x55909b,_0x5cc80c,_0x363469,_0x3de13c){this[_0x44de('0x8a')]=_0x44de('0x8b');this[_0x44de('0x8c')]=_0x55909b[_0x44de('0x8d')];this[_0x44de('0x8e')]=_0x3de13c;this['type']=_0x44de('0x8f');this[_0x44de('0x90')]=_0x44de('0x91');this['FaxAccountId']=_0x55909b['id'];this[_0x44de('0x92')]=_0x5cc80c;this[_0x44de('0x93')]=_0x363469;}function createExtensionsReciveFax(_0x4a7f95){var _0x1409db=0x1;var _0xcda330=[];_0xcda330[_0x44de('0x94')](new Extension(_0x4a7f95,_0x1409db,'','Answer'));_0x1409db+=0x1;_0xcda330['push'](new Extension(_0x4a7f95,_0x1409db,'CDR(type)=inbound-fax',_0x44de('0x95')));_0x1409db+=0x1;for(var _0x59ef45 in _0x4a7f95){if(_0x4a7f95[_0x44de('0x4f')](_0x59ef45)&&(_0x59ef45===_0x44de('0x96')||_0x59ef45==='localstationid'||_0x59ef45==='gateway'||_0x59ef45==='faxdetect'||_0x59ef45===_0x44de('0x97')||_0x59ef45===_0x44de('0x98')||_0x59ef45==='minrate'||_0x59ef45==='modem'||_0x59ef45===_0x44de('0x99'))){_0xcda330[_0x44de('0x94')](new Extension(_0x4a7f95,_0x1409db,_0x44de('0x9a')+_0x59ef45+')='+_0x4a7f95[_0x59ef45],_0x44de('0x95')));_0x1409db+=0x1;}}_0xcda330[_0x44de('0x94')](new Extension(_0x4a7f95,_0x1409db,'6','Wait'));_0x1409db+=0x1;_0xcda330[_0x44de('0x94')](new Extension(_0x4a7f95,_0x1409db,_0x44de('0x9b'),_0x44de('0x9c')));_0x1409db=0x0;return _0xcda330;}exports[_0x44de('0x9d')]=function(_0x2b8229,_0x4a9cfe,_0x1c98ff){var _0x49df0e;return db['sequelize']['transaction'](function(_0x37f78b){return db[_0x44de('0x57')][_0x44de('0x5f')](_0x2b8229[_0x44de('0x60')],{'transaction':_0x37f78b})[_0x44de('0x3a')](function(_0x226404){_0x49df0e=_0x226404[_0x44de('0x3b')]({'plain':!![]});return db[_0x44de('0x9e')][_0x44de('0x9f')](createExtensionsReciveFax(_0x49df0e),{'transaction':_0x37f78b});});})[_0x44de('0x3a')](function(){return _0x49df0e;})[_0x44de('0x3a')](respondWithResult(_0x4a9cfe,null))[_0x44de('0x2d')](handleError(_0x4a9cfe,null));};exports[_0x44de('0xa0')]=function(_0xa7262b,_0x565cf4,_0x36df8c){var _0x448ff5;return db[_0x44de('0x80')][_0x44de('0x81')](function(_0x5c24c6){return db['FaxAccount'][_0x44de('0x39')](_0xa7262b[_0x44de('0x60')],{'where':{'id':_0xa7262b['body']['id']},'transaction':_0x5c24c6})['then'](function(_0x1a8b00){return db[_0x44de('0x9e')][_0x44de('0x3e')]({'where':{'FaxAccountId':_0xa7262b[_0x44de('0x60')]['id']},'transaction':_0x5c24c6})[_0x44de('0x3a')](function(_0x3d8bd7){return db['VoiceExtension']['bulkCreate'](createExtensionsReciveFax(_[_0x44de('0x78')](_0xa7262b['body'],[_0x44de('0xa1'),'key',_0x44de('0xa2'),_0x44de('0xa3'),_0x44de('0xa4'),_0x44de('0xa5')])),{'transaction':_0x5c24c6});});});})[_0x44de('0x3a')](function(){return db[_0x44de('0x57')][_0x44de('0xa6')](_0xa7262b[_0x44de('0x60')]['id']);})[_0x44de('0x3a')](respondWithResult(_0x565cf4,null))[_0x44de('0x2d')](handleError(_0x565cf4,null));};exports[_0x44de('0xa7')]=function(_0x26046e,_0xb77e,_0x2b42c7){var _0x183ede={'raw':!![],'where':{}};var _0x2a2230={};var _0x4e5a2d={'count':0x0,'rows':[]};return db[_0x44de('0x57')][_0x44de('0x6d')]({'where':{'id':_0x26046e[_0x44de('0x67')]['id']}})[_0x44de('0x3a')](handleEntityNotFound(_0xb77e,null))[_0x44de('0x3a')](function(_0x56f84a){if(_0x56f84a){_0x2a2230[_0x44de('0x47')]=_['keys'](db['FaxMessage'][_0x44de('0x43')]);_0x2a2230[_0x44de('0x4a')]=_[_0x44de('0x49')](_0x26046e[_0x44de('0x4a')]);_0x2a2230[_0x44de('0x4b')]=_[_0x44de('0x4c')](_0x2a2230[_0x44de('0x47')],_0x2a2230['query']);_0x183ede[_0x44de('0x4e')]=_[_0x44de('0x4c')](_0x2a2230[_0x44de('0x47')],qs[_0x44de('0x4d')](_0x26046e[_0x44de('0x4a')]['fields']));_0x183ede[_0x44de('0x4e')]=_0x183ede[_0x44de('0x4e')][_0x44de('0x5c')]?_0x183ede['attributes']:_0x2a2230[_0x44de('0x47')];if(!_0x26046e['query'][_0x44de('0x4f')](_0x44de('0x50'))){_0x183ede[_0x44de('0x31')]=qs[_0x44de('0x31')](_0x26046e['query'][_0x44de('0x31')]);_0x183ede[_0x44de('0x30')]=qs[_0x44de('0x30')](_0x26046e[_0x44de('0x4a')]['offset']);}_0x183ede[_0x44de('0x51')]=qs[_0x44de('0x52')](_0x26046e['query'][_0x44de('0x52')]);_0x183ede[_0x44de('0x53')]=qs['filters'](_[_0x44de('0x6e')](_0x26046e[_0x44de('0x4a')],_0x2a2230[_0x44de('0x4b')]));_0x183ede[_0x44de('0x53')][_0x44de('0x6a')]=_0x56f84a['id'];if(_0x26046e[_0x44de('0x4a')][_0x44de('0x56')]){_0x183ede[_0x44de('0x53')]=_[_0x44de('0x54')](_0x183ede[_0x44de('0x53')],{'$or':_[_0x44de('0x48')](_0x183ede['attributes'],function(_0x1d3359){var _0x2f4178={};_0x2f4178[_0x1d3359]={'$like':'%'+_0x26046e[_0x44de('0x4a')][_0x44de('0x56')]+'%'};return _0x2f4178;})});}if(_0x26046e[_0x44de('0x4a')][_0x44de('0xa8')]){var _0x5c6bf5=_0x26046e[_0x44de('0x4a')]['$gte'][_0x44de('0xa9')](',');var _0x588724={};_0x588724[_0x5c6bf5[0x0]]={'$gte':moment(_0x5c6bf5[0x1])[_0x44de('0xaa')](_0x44de('0xab'))};_0x183ede[_0x44de('0x53')]=_[_0x44de('0x54')](_0x183ede[_0x44de('0x53')],_0x588724);}_0x183ede=_[_0x44de('0x54')]({},_0x183ede,_0x26046e[_0x44de('0x5d')]);return db['FaxMessage'][_0x44de('0x33')]({'where':_0x183ede[_0x44de('0x53')]})[_0x44de('0x3a')](function(_0x43efd5){_0x4e5a2d[_0x44de('0x33')]=_0x43efd5;if(_0x26046e[_0x44de('0x4a')][_0x44de('0x58')]){_0x183ede[_0x44de('0x59')]=[{'all':!![]}];}return db[_0x44de('0xac')][_0x44de('0x5a')](_0x183ede);})[_0x44de('0x3a')](function(_0x10bd4b){_0x4e5a2d[_0x44de('0x6f')]=_0x10bd4b;return _0x4e5a2d;});}})[_0x44de('0x3a')](respondWithFilteredResult(_0xb77e,_0x183ede))[_0x44de('0x2d')](handleError(_0xb77e,null));};exports[_0x44de('0x88')]=function(_0x521bd3,_0x402de9,_0x482971){var _0x294b1d,_0x3d2f43={},_0x459fd6;if(_0x521bd3['body']['to']){_0x459fd6=_0x521bd3[_0x44de('0x60')]['to'][0x0];}return db[_0x44de('0x57')][_0x44de('0x5e')]({'where':{'id':_0x521bd3['params']['id']},'include':[{'model':db[_0x44de('0xad')],'as':_0x44de('0xae'),'include':[{'model':db[_0x44de('0xaf')],'as':_0x44de('0xb0'),'where':{'fax':_0x459fd6},'limit':0x1,'order':[[_0x44de('0xa3'),_0x44de('0xb1')]]}]}]})[_0x44de('0x3a')](handleEntityNotFound(_0x402de9,null))[_0x44de('0x3a')](function(_0x5a2195){_0x294b1d=_0x5a2195;if(_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')]&&_0x521bd3['body']['attachments'][_0x44de('0x5c')]){for(var _0x2aad7d=0x0;_0x2aad7d<_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][_0x44de('0x5c')];_0x2aad7d+=0x1){_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][_0x2aad7d]={'filename':_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][_0x2aad7d][_0x44de('0x40')],'id':_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][_0x2aad7d]['id'],'path':path[_0x44de('0xb3')](config[_0x44de('0xb4')],'server/files/attachments',_0x521bd3[_0x44de('0x60')]['attachments'][_0x2aad7d][_0x44de('0xb5')])};}}return respondWithRpcPromise(_0x44de('0xb6'),_0x44de('0xb6'),{'FaxAccountId':_['isNil'](_0x521bd3[_0x44de('0x67')]['id'])?undefined:_0x521bd3[_0x44de('0x67')]['id'],'path':_[_0x44de('0xb7')](_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][0x0][_0x44de('0x7')])?undefined:_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][0x0][_0x44de('0x7')],'fax':_[_0x44de('0xb7')](_0x521bd3['body']['to'][0x0])?undefined:_0x521bd3[_0x44de('0x60')]['to'][0x0]},client9002);})[_0x44de('0x3a')](function(){if(_0x294b1d){if(_[_0x44de('0xb7')](_0x521bd3['body'][_0x44de('0xb8')])){_0x521bd3[_0x44de('0x60')][_0x44de('0xb8')]=util[_0x44de('0xaa')]('\x22%s\x22\x20<%s>',_0x294b1d[_0x44de('0x40')],_0x294b1d[_0x44de('0xb9')]);}if(_0x294b1d['List']){if(_0x294b1d[_0x44de('0xae')][_0x44de('0xb0')][_0x44de('0x5c')]){return _0x294b1d[_0x44de('0xae')][_0x44de('0xb0')][0x0];}else{return db['CmContact'][_0x44de('0x5f')](_['defaults'](_0x521bd3[_0x44de('0x60')],{'firstName':_0x521bd3[_0x44de('0x60')]['to'][0x0],'phone':_0x521bd3['body']['to'][0x0],'fax':_0x521bd3[_0x44de('0x60')]['to'][0x0],'ListId':_0x294b1d['ListId']}));}}else{throw new Error(_0x44de('0xba'));}}else{throw new Error('Send\x20Fax\x20failed');}})['then'](function(_0x348a95){if(_0x348a95){return db[_0x44de('0x77')][_0x44de('0x5e')]({'where':{'ContactId':_0x348a95['id'],'closed':![],'FaxAccountId':_0x294b1d['id']}})[_0x44de('0x3a')](function(_0x54e265){if(_0x54e265){return[_0x54e265,![]];}return db['FaxInteraction'][_0x44de('0x5f')]({'UserId':_0x521bd3[_0x44de('0x62')]['id'],'ContactId':_0x348a95['id'],'FaxAccountId':_0x294b1d['id'],'fax':_0x521bd3[_0x44de('0x60')]['to'][0x0],'firstMsgDirection':_0x44de('0xbb'),'Messages':[_[_0x44de('0x54')](_0x521bd3[_0x44de('0x60')],{'read':![],'body':_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][0x0][_0x44de('0xbc')],'FaxAccountId':_0x294b1d['id'],'UserId':_0x521bd3[_0x44de('0x62')]['id'],'ContactId':_0x348a95['id'],'AttachmentId':_0x521bd3[_0x44de('0x60')]['attachments'][0x0]['id']})]},{'include':[{'model':db[_0x44de('0xac')],'as':_0x44de('0xbd')}]})[_0x44de('0x3a')](function(_0x43308e){return[_0x43308e,!![]];});});}else{throw new Error(_0x44de('0xbe'));}})[_0x44de('0xbf')](function(_0x567ab7,_0x245844){if(_0x245844){return _0x567ab7;}return db[_0x44de('0xac')][_0x44de('0x5f')]({'direction':'out','read':![],'body':_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][0x0][_0x44de('0xbc')],'FaxAccountId':_0x294b1d['id'],'FaxInteractionId':_0x567ab7['id'],'UserId':_0x521bd3[_0x44de('0x62')]['id'],'ContactId':_0x567ab7[_0x44de('0xc0')],'AttachmentId':_0x521bd3['body'][_0x44de('0xb2')][0x0]['id']})[_0x44de('0x3a')](function(_0x10af17){_0x567ab7['dataValues']['Messages']=[];_0x567ab7[_0x44de('0xc1')][_0x44de('0xbd')]['push'](_0x10af17[_0x44de('0xc1')]);return _0x567ab7;});})[_0x44de('0x3a')](function(_0x51e791){respondWithRpcPromise(_0x44de('0xc2'),_0x44de('0xc2'),{'FaxAccountId':_[_0x44de('0xb7')](_0x521bd3['params']['id'])?undefined:_0x521bd3[_0x44de('0x67')]['id'],'path':_[_0x44de('0xb7')](_0x521bd3[_0x44de('0x60')]['attachments'][0x0][_0x44de('0x7')])?undefined:_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][0x0][_0x44de('0x7')],'fax':_[_0x44de('0xb7')](_0x521bd3[_0x44de('0x60')]['to'][0x0])?undefined:_0x521bd3[_0x44de('0x60')]['to'][0x0],'AttachmentId':_0x521bd3[_0x44de('0x60')][_0x44de('0xb2')][0x0]['id']},client9002)[_0x44de('0x3a')](function(_0xd6bce1){logger[_0x44de('0x24')](_0x44de('0xc3'),_0xd6bce1);})[_0x44de('0x2d')](function(_0x394cb4){logger[_0x44de('0x24')](_0x44de('0xc3'),_0x394cb4);});return _0x51e791;})[_0x44de('0x3a')](respondWithResult(_0x402de9,null))[_0x44de('0x2d')](handleError(_0x402de9,null));};exports[_0x44de('0xc4')]=function(_0x2cfcf3,_0x4fd5b7,_0x4e9104){return db[_0x44de('0x57')][_0x44de('0x5e')]({'where':{'id':_0x2cfcf3[_0x44de('0x67')]['id']}})[_0x44de('0x3a')](handleEntityNotFound(_0x4fd5b7,null))[_0x44de('0x3a')](function(_0x128954){if(_0x128954){return _0x128954[_0x44de('0xc4')](_0x2cfcf3[_0x44de('0x60')][_0x44de('0x71')],_[_0x44de('0x78')](_0x2cfcf3[_0x44de('0x60')],[_0x44de('0x71'),'id'])||{})[_0x44de('0xbf')](function(_0x1a442e){for(var _0xf4e5e3=0x0;_0xf4e5e3<_0x2cfcf3[_0x44de('0x60')]['ids'][_0x44de('0x5c')];_0xf4e5e3+=0x1){socket[_0x44de('0xc5')](_0x44de('0xc6'),{'UserId':Number(_0x2cfcf3['body'][_0x44de('0x71')][_0xf4e5e3]),'FaxAccountId':Number(_0x2cfcf3[_0x44de('0x67')]['id'])});}return _0x1a442e;});}})[_0x44de('0x3a')](respondWithResult(_0x4fd5b7,null))['catch'](handleError(_0x4fd5b7,null));};exports['removeAgents']=function(_0xe98f88,_0x7a59f7,_0x271445){return db[_0x44de('0x57')][_0x44de('0x5e')]({'where':{'id':_0xe98f88['params']['id']}})[_0x44de('0x3a')](handleEntityNotFound(_0x7a59f7,null))['then'](function(_0x3335c0){if(_0x3335c0){return _0x3335c0[_0x44de('0xc7')](_0xe98f88['query'][_0x44de('0x71')])[_0x44de('0x3a')](function(){if(_[_0x44de('0xc8')](_0xe98f88['query'][_0x44de('0x71')])){for(var _0x2bf3d0=0x0;_0x2bf3d0<_0xe98f88[_0x44de('0x4a')][_0x44de('0x71')][_0x44de('0x5c')];_0x2bf3d0+=0x1){socket[_0x44de('0xc5')](_0x44de('0xc9'),{'UserId':Number(_0xe98f88[_0x44de('0x4a')]['ids'][_0x2bf3d0]),'FaxAccountId':Number(_0xe98f88[_0x44de('0x67')]['id'])});}}else{socket[_0x44de('0xc5')](_0x44de('0xc9'),{'UserId':Number(_0xe98f88[_0x44de('0x4a')]['ids']),'FaxAccountId':Number(_0xe98f88['params']['id'])});}});}})[_0x44de('0x3a')](respondWithStatusCode(_0x7a59f7,null))[_0x44de('0x2d')](handleError(_0x7a59f7,null));};exports[_0x44de('0xca')]=function(_0x452c29,_0x2aec6d,_0x2e4e88){var _0x5b3449={};var _0x562952={};var _0x46d477;var _0x52aaf8;return db[_0x44de('0x57')]['findOne']({'where':{'id':_0x452c29['params']['id']}})[_0x44de('0x3a')](handleEntityNotFound(_0x2aec6d,null))['then'](function(_0x2f7255){if(_0x2f7255){_0x46d477=_0x2f7255;_0x562952[_0x44de('0x47')]=_['keys'](db[_0x44de('0xcb')][_0x44de('0x43')]);_0x562952[_0x44de('0x4a')]=_['keys'](_0x452c29[_0x44de('0x4a')]);_0x562952[_0x44de('0x4b')]=_[_0x44de('0x4c')](_0x562952[_0x44de('0x47')],_0x562952['query']);_0x5b3449['attributes']=_['intersection'](_0x562952[_0x44de('0x47')],qs[_0x44de('0x4d')](_0x452c29[_0x44de('0x4a')][_0x44de('0x4d')]));_0x5b3449['attributes']=_0x5b3449['attributes'][_0x44de('0x5c')]?_0x5b3449[_0x44de('0x4e')]:_0x562952[_0x44de('0x47')];_0x5b3449[_0x44de('0x51')]=qs[_0x44de('0x52')](_0x452c29[_0x44de('0x4a')][_0x44de('0x52')]);_0x5b3449[_0x44de('0x53')]=qs[_0x44de('0x4b')](_[_0x44de('0x6e')](_0x452c29[_0x44de('0x4a')],_0x562952[_0x44de('0x4b')]));if(_0x452c29[_0x44de('0x4a')][_0x44de('0x56')]){_0x5b3449['where']=_[_0x44de('0x54')](_0x5b3449['where'],{'$or':_[_0x44de('0x48')](_0x5b3449[_0x44de('0x4e')],function(_0x2cd2ee){var _0x1f8c99={};_0x1f8c99[_0x2cd2ee]={'$like':'%'+_0x452c29['query']['filter']+'%'};return _0x1f8c99;})});}_0x5b3449=_['merge']({},_0x5b3449,_0x452c29[_0x44de('0x5d')]);return _0x46d477[_0x44de('0xca')](_0x5b3449);}})[_0x44de('0x3a')](function(_0x19d2a8){if(_0x19d2a8){_0x52aaf8=_0x19d2a8[_0x44de('0x5c')];if(!_0x452c29[_0x44de('0x4a')][_0x44de('0x4f')]('nolimit')){_0x5b3449[_0x44de('0x31')]=qs[_0x44de('0x31')](_0x452c29[_0x44de('0x4a')][_0x44de('0x31')]);_0x5b3449[_0x44de('0x30')]=qs[_0x44de('0x30')](_0x452c29[_0x44de('0x4a')][_0x44de('0x30')]);}return _0x46d477[_0x44de('0xca')](_0x5b3449);}})[_0x44de('0x3a')](function(_0x53917d){if(_0x53917d){return _0x53917d?{'count':_0x52aaf8,'rows':_0x53917d}:null;}})[_0x44de('0x3a')](respondWithResult(_0x2aec6d,null))[_0x44de('0x2d')](handleError(_0x2aec6d,null));};
\ No newline at end of file
+var _0x2e00=['findAndCountAll','priority','finally','getApplications','context','localstationid','app','description','appdata','push','Answer','CDR(type)=inbound-fax','Set','gateway','faxdetect','headerinfo','modem','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','addAccountApplications','VoiceExtension','updateAccountApplications','tech','createdAt','updatedAt','TrunkId','findById','getMessages','FaxMessage','nolimit','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','Contacts','DESC','attachments','join','root','server/files/attachments','basename','CheckAfterSend','isNil','\x22%s\x22\x20<%s>','fax','ListId','List\x20not\x20found','Send\x20Fax\x20failed','out','filename','Messages','ContactId','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','userFaxAccount:save','removeAgents','isArray','emit','userFaxAccount:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','register','client','http','FaxAccount,\x20%s,\x20%s','request\x20sent','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','code','error','message','info','catch','sendStatus','status','offset','undefined','count','limit','Content-Range','json','reject','save','update','then','destroy','get','FaxAccounts','UserProfileResource','end','stack','name','send','index','Pause','mandatoryDispositionPause','map','rawAttributes','type','key','model','query','keys','filters','fields','attributes','length','hasOwnProperty','sort','pick','where','merge','VIRTUAL','filter','FaxAccount','include','findAll','rows','show','params','intersection','includeAll','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','body','describe','addDisposition','Disposition','findOne','order','options','removeDispositions','ids','addAnswer','FaxAccountId','getAnswers','CannedAnswer','removeAnswers','addInteraction','omit','getInteractions','FaxInteraction','CmContact','Contact','User','fullname','internal','Tag','Tags','color','tag','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','bulkCreate','FaxApplication'];(function(_0x585fce,_0x48b828){var _0x17b9bf=function(_0xccac6e){while(--_0xccac6e){_0x585fce['push'](_0x585fce['shift']());}};_0x17b9bf(++_0x48b828);}(_0x2e00,0x1c3));var _0x02e0=function(_0x3186aa,_0x34c21e){_0x3186aa=_0x3186aa-0x0;var _0x2d8c36=_0x2e00[_0x3186aa];return _0x2d8c36;};'use strict';var emlformat=require(_0x02e0('0x0'));var rimraf=require(_0x02e0('0x1'));var zipdir=require(_0x02e0('0x2'));var jsonpatch=require(_0x02e0('0x3'));var rp=require('request-promise');var moment=require(_0x02e0('0x4'));var BPromise=require(_0x02e0('0x5'));var Mustache=require('mustache');var util=require(_0x02e0('0x6'));var path=require(_0x02e0('0x7'));var sox=require('sox');var csv=require(_0x02e0('0x8'));var ejs=require(_0x02e0('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x02e0('0xa'));var crypto=require(_0x02e0('0xb'));var jsforce=require(_0x02e0('0xc'));var deskjs=require(_0x02e0('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x02e0('0xe'));var Redis=require(_0x02e0('0xf'));var authService=require(_0x02e0('0x10'));var qs=require(_0x02e0('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x02e0('0x12'));var utils=require(_0x02e0('0x13'));var config=require(_0x02e0('0x14'));var licenseUtil=require(_0x02e0('0x15'));var db=require(_0x02e0('0x16'))['db'];config[_0x02e0('0x17')]=_[_0x02e0('0x18')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x02e0('0x19'))(new Redis(config[_0x02e0('0x17')]));require('./faxAccount.socket')[_0x02e0('0x1a')](socket);var jayson=require('jayson/promise');var client=jayson[_0x02e0('0x1b')][_0x02e0('0x1c')]({'port':0x232c});var client9002=jayson[_0x02e0('0x1b')]['http']({'port':0x232a});function respondWithRpcPromise(_0x506409,_0x2920f2,_0x143767,_0x5e392e){return new BPromise(function(_0x2a385a,_0x53d85b){var _0x8f8548=_0x5e392e||client;return _0x8f8548['request'](_0x506409,_0x143767)['then'](function(_0x1181c6){logger['info'](_0x02e0('0x1d'),_0x2920f2,_0x02e0('0x1e'));logger['debug'](_0x02e0('0x1f'),_0x2920f2,_0x02e0('0x1e'),JSON[_0x02e0('0x20')](_0x1181c6));if(_0x1181c6['error']){if(_0x1181c6['error'][_0x02e0('0x21')]===0x1f4){logger[_0x02e0('0x22')](_0x02e0('0x1d'),_0x2920f2,_0x1181c6[_0x02e0('0x22')][_0x02e0('0x23')]);return _0x53d85b(_0x1181c6[_0x02e0('0x22')]['message']);}logger[_0x02e0('0x22')](_0x02e0('0x1d'),_0x2920f2,_0x1181c6[_0x02e0('0x22')][_0x02e0('0x23')]);return _0x2a385a(_0x1181c6[_0x02e0('0x22')][_0x02e0('0x23')]);}else{logger[_0x02e0('0x24')](_0x02e0('0x1d'),_0x2920f2,_0x02e0('0x1e'));_0x2a385a(_0x1181c6['result'][_0x02e0('0x23')]);}})[_0x02e0('0x25')](function(_0x1f7db6){logger[_0x02e0('0x22')](_0x02e0('0x1d'),_0x2920f2,_0x1f7db6);_0x53d85b(_0x1f7db6);});});}function respondWithStatusCode(_0x1798e1,_0x5de275){_0x5de275=_0x5de275||0xcc;return function(_0x15c1a0){if(_0x15c1a0){return _0x1798e1[_0x02e0('0x26')](_0x5de275);}return _0x1798e1[_0x02e0('0x27')](_0x5de275)['end']();};}function respondWithResult(_0x526a1c,_0x1d3d5e){_0x1d3d5e=_0x1d3d5e||0xc8;return function(_0x1b4fd7){if(_0x1b4fd7){return _0x526a1c['status'](_0x1d3d5e)['json'](_0x1b4fd7);}};}function respondWithFilteredResult(_0x5ec99e,_0x4cc146){return function(_0x390e77){if(_0x390e77){var _0x56d413=typeof _0x4cc146[_0x02e0('0x28')]===_0x02e0('0x29')&&typeof _0x4cc146['limit']==='undefined';var _0xa85da7=_0x390e77[_0x02e0('0x2a')];var _0x369f68=_0x56d413?0x0:_0x4cc146[_0x02e0('0x28')];var _0x5b5897=_0x56d413?_0x390e77['count']:_0x4cc146[_0x02e0('0x28')]+_0x4cc146[_0x02e0('0x2b')];var _0x3f7d0f;if(_0x5b5897>=_0xa85da7){_0x5b5897=_0xa85da7;_0x3f7d0f=0xc8;}else{_0x3f7d0f=0xce;}_0x5ec99e[_0x02e0('0x27')](_0x3f7d0f);return _0x5ec99e['set'](_0x02e0('0x2c'),_0x369f68+'-'+_0x5b5897+'/'+_0xa85da7)[_0x02e0('0x2d')](_0x390e77);}return null;};}function patchUpdates(_0x1d41dc){return function(_0x15e2d1){try{jsonpatch['apply'](_0x15e2d1,_0x1d41dc,!![]);}catch(_0x4e587f){return BPromise[_0x02e0('0x2e')](_0x4e587f);}return _0x15e2d1[_0x02e0('0x2f')]();};}function saveUpdates(_0x51468d,_0x1eae2b){return function(_0x414f73){if(_0x414f73){return _0x414f73[_0x02e0('0x30')](_0x51468d)[_0x02e0('0x31')](function(_0x2b1610){return _0x2b1610;});}return null;};}function removeEntity(_0x50670c,_0x296271){return function(_0x4801bb){if(_0x4801bb){return _0x4801bb[_0x02e0('0x32')]()[_0x02e0('0x31')](function(){var _0x5900df=_0x4801bb[_0x02e0('0x33')]({'plain':!![]});var _0x38fddc=_0x02e0('0x34');return db[_0x02e0('0x35')][_0x02e0('0x32')]({'where':{'type':_0x38fddc,'resourceId':_0x5900df['id']}})[_0x02e0('0x31')](function(){return _0x4801bb;});})['then'](function(){_0x50670c['status'](0xcc)[_0x02e0('0x36')]();});}};}function handleEntityNotFound(_0x56c552,_0x4bb092){return function(_0x1e1411){if(!_0x1e1411){_0x56c552[_0x02e0('0x26')](0x194);}return _0x1e1411;};}function handleError(_0x471a36,_0x5924bf){_0x5924bf=_0x5924bf||0x1f4;return function(_0x47fe3d){logger['error'](_0x47fe3d[_0x02e0('0x37')]);if(_0x47fe3d[_0x02e0('0x38')]){delete _0x47fe3d[_0x02e0('0x38')];}_0x471a36[_0x02e0('0x27')](_0x5924bf)[_0x02e0('0x39')](_0x47fe3d);};}exports[_0x02e0('0x3a')]=function(_0x135225,_0x4abdbc){var _0x5d0953={'include':[{'model':db[_0x02e0('0x3b')],'as':_0x02e0('0x3c')}]},_0x434a1f={},_0x5c0664={'count':0x0,'rows':[]};var _0xb1ed8c=_[_0x02e0('0x3d')](db['FaxAccount'][_0x02e0('0x3e')],function(_0x42ca51){return{'name':_0x42ca51['fieldName'],'type':_0x42ca51[_0x02e0('0x3f')][_0x02e0('0x40')]};});_0x434a1f[_0x02e0('0x41')]=_['map'](_0xb1ed8c,_0x02e0('0x38'));_0x434a1f[_0x02e0('0x42')]=_[_0x02e0('0x43')](_0x135225[_0x02e0('0x42')]);_0x434a1f[_0x02e0('0x44')]=_['intersection'](_0x434a1f[_0x02e0('0x41')],_0x434a1f[_0x02e0('0x42')]);_0x5d0953['attributes']=_['intersection'](_0x434a1f[_0x02e0('0x41')],qs['fields'](_0x135225[_0x02e0('0x42')][_0x02e0('0x45')]));_0x5d0953[_0x02e0('0x46')]=_0x5d0953[_0x02e0('0x46')][_0x02e0('0x47')]?_0x5d0953[_0x02e0('0x46')]:_0x434a1f['model'];if(!_0x135225[_0x02e0('0x42')][_0x02e0('0x48')]('nolimit')){_0x5d0953[_0x02e0('0x2b')]=qs[_0x02e0('0x2b')](_0x135225[_0x02e0('0x42')]['limit']);_0x5d0953[_0x02e0('0x28')]=qs[_0x02e0('0x28')](_0x135225[_0x02e0('0x42')][_0x02e0('0x28')]);}_0x5d0953['order']=qs[_0x02e0('0x49')](_0x135225[_0x02e0('0x42')]['sort']);_0x5d0953['where']=qs[_0x02e0('0x44')](_[_0x02e0('0x4a')](_0x135225[_0x02e0('0x42')],_0x434a1f[_0x02e0('0x44')]),_0xb1ed8c);if(_0x135225['query']['filter']){_0x5d0953[_0x02e0('0x4b')]=_[_0x02e0('0x4c')](_0x5d0953[_0x02e0('0x4b')],{'$or':_[_0x02e0('0x3d')](_0xb1ed8c,function(_0x36bdd8){if(_0x36bdd8[_0x02e0('0x3f')]!==_0x02e0('0x4d')){var _0x372317={};_0x372317[_0x36bdd8[_0x02e0('0x38')]]={'$like':'%'+_0x135225['query'][_0x02e0('0x4e')]+'%'};return _0x372317;}})});}_0x5d0953=_[_0x02e0('0x4c')]({},_0x5d0953,_0x135225['options']);var _0x222fc8={'where':_0x5d0953['where']};return db[_0x02e0('0x4f')][_0x02e0('0x2a')](_0x222fc8)[_0x02e0('0x31')](function(_0x2fc0ab){_0x5c0664[_0x02e0('0x2a')]=_0x2fc0ab;if(_0x135225[_0x02e0('0x42')]['includeAll']){_0x5d0953[_0x02e0('0x50')]=[{'all':!![]}];}return db[_0x02e0('0x4f')][_0x02e0('0x51')](_0x5d0953);})[_0x02e0('0x31')](function(_0x4c5ea0){_0x5c0664[_0x02e0('0x52')]=_0x4c5ea0;return _0x5c0664;})[_0x02e0('0x31')](respondWithFilteredResult(_0x4abdbc,_0x5d0953))[_0x02e0('0x25')](handleError(_0x4abdbc,null));};exports[_0x02e0('0x53')]=function(_0x502509,_0x233426){var _0x5eba90={'raw':![],'where':{'id':_0x502509[_0x02e0('0x54')]['id']},'include':[{'model':db[_0x02e0('0x3b')],'as':'mandatoryDispositionPause'}]},_0x8ae18b={};_0x8ae18b[_0x02e0('0x41')]=_[_0x02e0('0x43')](db['FaxAccount'][_0x02e0('0x3e')]);_0x8ae18b[_0x02e0('0x42')]=_['keys'](_0x502509[_0x02e0('0x42')]);_0x8ae18b[_0x02e0('0x44')]=_[_0x02e0('0x55')](_0x8ae18b['model'],_0x8ae18b['query']);_0x5eba90[_0x02e0('0x46')]=_['intersection'](_0x8ae18b[_0x02e0('0x41')],qs[_0x02e0('0x45')](_0x502509[_0x02e0('0x42')][_0x02e0('0x45')]));_0x5eba90['attributes']=_0x5eba90[_0x02e0('0x46')]['length']?_0x5eba90['attributes']:_0x8ae18b['model'];if(_0x502509[_0x02e0('0x42')][_0x02e0('0x56')]){_0x5eba90[_0x02e0('0x50')]=[{'all':!![]}];}_0x5eba90=_['merge']({},_0x5eba90,_0x502509['options']);return db['FaxAccount'][_0x02e0('0x57')](_0x5eba90)[_0x02e0('0x31')](handleEntityNotFound(_0x233426,null))[_0x02e0('0x31')](respondWithResult(_0x233426,null))['catch'](handleError(_0x233426,null));};exports[_0x02e0('0x58')]=function(_0x481fdc,_0x160324){return db[_0x02e0('0x4f')][_0x02e0('0x58')](_0x481fdc['body'],{})[_0x02e0('0x31')](function(_0x1cdd91){var _0x12ff61=_0x481fdc[_0x02e0('0x59')][_0x02e0('0x33')]({'plain':!![]});if(!_0x12ff61)throw new Error(_0x02e0('0x5a'));if(_0x12ff61['role']===_0x02e0('0x59')){var _0x1fd43c=_0x1cdd91[_0x02e0('0x33')]({'plain':!![]});var _0x506859='FaxAccounts';return db[_0x02e0('0x5b')]['find']({'where':{'name':_0x506859,'userProfileId':_0x12ff61[_0x02e0('0x5c')]},'raw':!![]})[_0x02e0('0x31')](function(_0x12fffa){if(_0x12fffa&&_0x12fffa[_0x02e0('0x5d')]===0x0){return db[_0x02e0('0x35')]['create']({'name':_0x1fd43c[_0x02e0('0x38')],'resourceId':_0x1fd43c['id'],'type':_0x12fffa[_0x02e0('0x38')],'sectionId':_0x12fffa['id']},{})[_0x02e0('0x31')](function(){return _0x1cdd91;});}else{return _0x1cdd91;}})[_0x02e0('0x25')](function(_0x5cb433){logger[_0x02e0('0x22')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5cb433);throw _0x5cb433;});}return _0x1cdd91;})['then'](respondWithResult(_0x160324,0xc9))['catch'](handleError(_0x160324,null));};exports[_0x02e0('0x30')]=function(_0x366e43,_0x1faae7){if(_0x366e43['body']['id']){delete _0x366e43[_0x02e0('0x5e')]['id'];}return db[_0x02e0('0x4f')][_0x02e0('0x57')]({'where':{'id':_0x366e43[_0x02e0('0x54')]['id']},'include':[{'model':db[_0x02e0('0x3b')],'as':_0x02e0('0x3c')}]})[_0x02e0('0x31')](handleEntityNotFound(_0x1faae7,null))[_0x02e0('0x31')](saveUpdates(_0x366e43[_0x02e0('0x5e')],null))['then'](respondWithResult(_0x1faae7,null))[_0x02e0('0x25')](handleError(_0x1faae7,null));};exports[_0x02e0('0x32')]=function(_0x2fe519,_0x742b59){return db[_0x02e0('0x4f')][_0x02e0('0x57')]({'where':{'id':_0x2fe519[_0x02e0('0x54')]['id']}})['then'](handleEntityNotFound(_0x742b59,null))[_0x02e0('0x31')](removeEntity(_0x742b59,null))[_0x02e0('0x25')](handleError(_0x742b59,null));};exports[_0x02e0('0x5f')]=function(_0xf25eea,_0x21461c){return db[_0x02e0('0x4f')]['describe']()[_0x02e0('0x31')](respondWithResult(_0x21461c,null))[_0x02e0('0x25')](handleError(_0x21461c,null));};exports[_0x02e0('0x60')]=function(_0x154f14,_0xda6aac,_0x178dca){if(_0x154f14[_0x02e0('0x5e')]['id']){delete _0x154f14[_0x02e0('0x5e')]['id'];}return db[_0x02e0('0x4f')][_0x02e0('0x57')]({'where':{'id':_0x154f14[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0xda6aac,null))[_0x02e0('0x31')](function(_0x50f0d6){if(_0x50f0d6){_0x154f14[_0x02e0('0x5e')]['FaxAccountId']=_0x50f0d6['id'];return db[_0x02e0('0x61')][_0x02e0('0x58')](_0x154f14[_0x02e0('0x5e')]);}})[_0x02e0('0x31')](respondWithResult(_0xda6aac,null))[_0x02e0('0x25')](handleError(_0xda6aac,null));};exports['getDispositions']=function(_0x4fbdb6,_0x1c4944,_0x2d3192){var _0x3d78d2={'raw':![],'where':{}};var _0x165a09={};var _0x47b412={'count':0x0,'rows':[]};return db['FaxAccount'][_0x02e0('0x62')]({'where':{'id':_0x4fbdb6['params']['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x1c4944,null))[_0x02e0('0x31')](function(_0x51dd35){if(_0x51dd35){_0x165a09[_0x02e0('0x41')]=_[_0x02e0('0x43')](db[_0x02e0('0x61')][_0x02e0('0x3e')]);_0x165a09[_0x02e0('0x42')]=_[_0x02e0('0x43')](_0x4fbdb6[_0x02e0('0x42')]);_0x165a09[_0x02e0('0x44')]=_[_0x02e0('0x55')](_0x165a09[_0x02e0('0x41')],_0x165a09[_0x02e0('0x42')]);_0x3d78d2[_0x02e0('0x46')]=_[_0x02e0('0x55')](_0x165a09[_0x02e0('0x41')],qs['fields'](_0x4fbdb6[_0x02e0('0x42')][_0x02e0('0x45')]));_0x3d78d2[_0x02e0('0x46')]=_0x3d78d2['attributes'][_0x02e0('0x47')]?_0x3d78d2[_0x02e0('0x46')]:_0x165a09[_0x02e0('0x41')];if(!_0x4fbdb6[_0x02e0('0x42')][_0x02e0('0x48')]('nolimit')){_0x3d78d2[_0x02e0('0x2b')]=qs[_0x02e0('0x2b')](_0x4fbdb6[_0x02e0('0x42')][_0x02e0('0x2b')]);_0x3d78d2[_0x02e0('0x28')]=qs[_0x02e0('0x28')](_0x4fbdb6['query'][_0x02e0('0x28')]);}_0x3d78d2[_0x02e0('0x63')]=qs[_0x02e0('0x49')](_0x4fbdb6[_0x02e0('0x42')][_0x02e0('0x49')]);_0x3d78d2['where']=qs['filters'](_[_0x02e0('0x4a')](_0x4fbdb6[_0x02e0('0x42')],_0x165a09['filters']));_0x3d78d2['where']['FaxAccountId']=_0x51dd35['id'];if(_0x4fbdb6[_0x02e0('0x42')][_0x02e0('0x4e')]){_0x3d78d2[_0x02e0('0x4b')]=_[_0x02e0('0x4c')](_0x3d78d2[_0x02e0('0x4b')],{'$or':_[_0x02e0('0x3d')](_0x3d78d2['attributes'],function(_0x4151bf){var _0xbc3812={};_0xbc3812[_0x4151bf]={'$like':'%'+_0x4fbdb6['query'][_0x02e0('0x4e')]+'%'};return _0xbc3812;})});}_0x3d78d2=_['merge']({},_0x3d78d2,_0x4fbdb6[_0x02e0('0x64')]);return db[_0x02e0('0x61')][_0x02e0('0x2a')]({'where':_0x3d78d2['where']})['then'](function(_0x131eef){_0x47b412[_0x02e0('0x2a')]=_0x131eef;if(_0x4fbdb6[_0x02e0('0x42')][_0x02e0('0x56')]){_0x3d78d2[_0x02e0('0x50')]=[{'all':!![]}];}return db[_0x02e0('0x61')]['findAll'](_0x3d78d2);})[_0x02e0('0x31')](function(_0x3d38eb){_0x47b412['rows']=_0x3d38eb;return _0x47b412;});}})[_0x02e0('0x31')](respondWithFilteredResult(_0x1c4944,_0x3d78d2))[_0x02e0('0x25')](handleError(_0x1c4944,null));};exports[_0x02e0('0x65')]=function(_0x201df6,_0x420e5e,_0x32d081){return db[_0x02e0('0x4f')]['find']({'where':{'id':_0x201df6['params']['id']}})['then'](handleEntityNotFound(_0x420e5e,null))[_0x02e0('0x31')](function(_0x1d2a6b){if(_0x1d2a6b){return _0x1d2a6b[_0x02e0('0x65')](_0x201df6[_0x02e0('0x42')][_0x02e0('0x66')]);}})['then'](respondWithStatusCode(_0x420e5e,null))[_0x02e0('0x25')](handleError(_0x420e5e,null));};exports[_0x02e0('0x67')]=function(_0x1a1c10,_0x1fe642,_0xf60034){if(_0x1a1c10[_0x02e0('0x5e')]['id']){delete _0x1a1c10[_0x02e0('0x5e')]['id'];}return db[_0x02e0('0x4f')][_0x02e0('0x57')]({'where':{'id':_0x1a1c10[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x1fe642,null))[_0x02e0('0x31')](function(_0x496d7d){if(_0x496d7d){_0x1a1c10[_0x02e0('0x5e')][_0x02e0('0x68')]=_0x496d7d['id'];return db['CannedAnswer'][_0x02e0('0x58')](_0x1a1c10[_0x02e0('0x5e')]);}})[_0x02e0('0x31')](respondWithResult(_0x1fe642,null))[_0x02e0('0x25')](handleError(_0x1fe642,null));};exports[_0x02e0('0x69')]=function(_0xd3b8a8,_0x271cb5,_0x2c83ad){var _0x286bac={'raw':![],'where':{}};var _0x4b57d1={};var _0x39be0f={'count':0x0,'rows':[]};return db[_0x02e0('0x4f')]['findOne']({'where':{'id':_0xd3b8a8[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x271cb5,null))[_0x02e0('0x31')](function(_0x490e73){if(_0x490e73){_0x4b57d1[_0x02e0('0x41')]=_[_0x02e0('0x43')](db[_0x02e0('0x6a')][_0x02e0('0x3e')]);_0x4b57d1[_0x02e0('0x42')]=_['keys'](_0xd3b8a8['query']);_0x4b57d1['filters']=_['intersection'](_0x4b57d1['model'],_0x4b57d1[_0x02e0('0x42')]);_0x286bac[_0x02e0('0x46')]=_[_0x02e0('0x55')](_0x4b57d1[_0x02e0('0x41')],qs[_0x02e0('0x45')](_0xd3b8a8[_0x02e0('0x42')][_0x02e0('0x45')]));_0x286bac['attributes']=_0x286bac[_0x02e0('0x46')]['length']?_0x286bac['attributes']:_0x4b57d1[_0x02e0('0x41')];if(!_0xd3b8a8[_0x02e0('0x42')]['hasOwnProperty']('nolimit')){_0x286bac[_0x02e0('0x2b')]=qs[_0x02e0('0x2b')](_0xd3b8a8[_0x02e0('0x42')][_0x02e0('0x2b')]);_0x286bac[_0x02e0('0x28')]=qs[_0x02e0('0x28')](_0xd3b8a8[_0x02e0('0x42')][_0x02e0('0x28')]);}_0x286bac[_0x02e0('0x63')]=qs[_0x02e0('0x49')](_0xd3b8a8['query']['sort']);_0x286bac['where']=qs[_0x02e0('0x44')](_[_0x02e0('0x4a')](_0xd3b8a8['query'],_0x4b57d1[_0x02e0('0x44')]));_0x286bac[_0x02e0('0x4b')]['FaxAccountId']=_0x490e73['id'];if(_0xd3b8a8[_0x02e0('0x42')][_0x02e0('0x4e')]){_0x286bac[_0x02e0('0x4b')]=_[_0x02e0('0x4c')](_0x286bac[_0x02e0('0x4b')],{'$or':_[_0x02e0('0x3d')](_0x286bac[_0x02e0('0x46')],function(_0x470f3e){var _0x34b67c={};_0x34b67c[_0x470f3e]={'$like':'%'+_0xd3b8a8[_0x02e0('0x42')][_0x02e0('0x4e')]+'%'};return _0x34b67c;})});}_0x286bac=_[_0x02e0('0x4c')]({},_0x286bac,_0xd3b8a8[_0x02e0('0x64')]);return db[_0x02e0('0x6a')]['count']({'where':_0x286bac[_0x02e0('0x4b')]})[_0x02e0('0x31')](function(_0x26387d){_0x39be0f['count']=_0x26387d;if(_0xd3b8a8[_0x02e0('0x42')][_0x02e0('0x56')]){_0x286bac[_0x02e0('0x50')]=[{'all':!![]}];}return db[_0x02e0('0x6a')][_0x02e0('0x51')](_0x286bac);})['then'](function(_0x504a83){_0x39be0f[_0x02e0('0x52')]=_0x504a83;return _0x39be0f;});}})['then'](respondWithFilteredResult(_0x271cb5,_0x286bac))[_0x02e0('0x25')](handleError(_0x271cb5,null));};exports[_0x02e0('0x6b')]=function(_0x38e0d9,_0x4923f4,_0x29d4fc){return db[_0x02e0('0x4f')][_0x02e0('0x57')]({'where':{'id':_0x38e0d9[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x4923f4,null))[_0x02e0('0x31')](function(_0x38c4ee){if(_0x38c4ee){return _0x38c4ee[_0x02e0('0x6b')](_0x38e0d9[_0x02e0('0x42')]['ids']);}})[_0x02e0('0x31')](respondWithStatusCode(_0x4923f4,null))[_0x02e0('0x25')](handleError(_0x4923f4,null));};exports[_0x02e0('0x6c')]=function(_0x2bbc7b,_0xdf5b0a,_0x1c2a57){return db['FaxInteraction'][_0x02e0('0x57')]({'where':{'id':_0x2bbc7b[_0x02e0('0x54')]['id']}})['then'](handleEntityNotFound(_0xdf5b0a,null))[_0x02e0('0x31')](function(_0x155684){if(_0x155684){return _0x155684[_0x02e0('0x6c')](_0x2bbc7b[_0x02e0('0x5e')][_0x02e0('0x66')],_[_0x02e0('0x6d')](_0x2bbc7b['body'],['ids','id'])||{});}})[_0x02e0('0x31')](respondWithResult(_0xdf5b0a,null))[_0x02e0('0x25')](handleError(_0xdf5b0a,null));};exports[_0x02e0('0x6e')]=function(_0x33cf6b,_0x4b5e01,_0x58f5d0){var _0x36c157={'raw':![],'where':{}};var _0x418c94={};var _0x2bc67a={'count':0x0,'rows':[]};return db[_0x02e0('0x4f')][_0x02e0('0x62')]({'where':{'id':_0x33cf6b[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x4b5e01,null))['then'](function(_0x5e57d1){if(_0x5e57d1){_0x418c94[_0x02e0('0x41')]=_[_0x02e0('0x43')](db['FaxInteraction'][_0x02e0('0x3e')]);_0x418c94[_0x02e0('0x42')]=_[_0x02e0('0x43')](_0x33cf6b[_0x02e0('0x42')]);_0x418c94[_0x02e0('0x44')]=_[_0x02e0('0x55')](_0x418c94[_0x02e0('0x41')],_0x418c94[_0x02e0('0x42')]);_0x36c157[_0x02e0('0x46')]=_[_0x02e0('0x55')](_0x418c94[_0x02e0('0x41')],qs[_0x02e0('0x45')](_0x33cf6b['query']['fields']));_0x36c157[_0x02e0('0x46')]=_0x36c157[_0x02e0('0x46')][_0x02e0('0x47')]?_0x36c157[_0x02e0('0x46')]:_0x418c94['model'];if(!_0x33cf6b['query'][_0x02e0('0x48')]('nolimit')){_0x36c157['limit']=qs['limit'](_0x33cf6b[_0x02e0('0x42')][_0x02e0('0x2b')]);_0x36c157['offset']=qs['offset'](_0x33cf6b[_0x02e0('0x42')][_0x02e0('0x28')]);}_0x36c157[_0x02e0('0x63')]=qs[_0x02e0('0x49')](_0x33cf6b[_0x02e0('0x42')][_0x02e0('0x49')]);_0x36c157[_0x02e0('0x4b')]=qs[_0x02e0('0x44')](_['pick'](_0x33cf6b[_0x02e0('0x42')],_0x418c94[_0x02e0('0x44')]));_0x36c157[_0x02e0('0x4b')][_0x02e0('0x68')]=_0x5e57d1['id'];if(_0x33cf6b[_0x02e0('0x42')]['filter']){_0x36c157['where']=_['merge'](_0x36c157[_0x02e0('0x4b')],{'$or':_[_0x02e0('0x3d')](_0x36c157[_0x02e0('0x46')],function(_0x2113b7){var _0x279979={};_0x279979[_0x2113b7]={'$like':'%'+_0x33cf6b[_0x02e0('0x42')]['filter']+'%'};return _0x279979;})});}_0x36c157=_[_0x02e0('0x4c')]({},_0x36c157,_0x33cf6b[_0x02e0('0x64')]);return db[_0x02e0('0x6f')][_0x02e0('0x2a')]({'where':_0x36c157[_0x02e0('0x4b')]})[_0x02e0('0x31')](function(_0x13566e){_0x2bc67a[_0x02e0('0x2a')]=_0x13566e;if(_0x33cf6b['query']['includeAll']){_0x36c157['include']=[{'model':db[_0x02e0('0x70')],'as':_0x02e0('0x71'),'required':![]},{'model':db[_0x02e0('0x72')],'as':'Owner','attributes':['name',_0x02e0('0x73'),_0x02e0('0x74')],'required':![]},{'model':db[_0x02e0('0x75')],'as':_0x02e0('0x76'),'attributes':['id',_0x02e0('0x38'),_0x02e0('0x77')],'where':_0x33cf6b[_0x02e0('0x42')]['tag']?{'id':_0x33cf6b[_0x02e0('0x42')]['tag']}:undefined,'required':_0x33cf6b['query'][_0x02e0('0x78')]?!![]:![]}];}return db['FaxInteraction']['findAll'](_0x36c157);})[_0x02e0('0x31')](function(_0x151503){_0x2bc67a[_0x02e0('0x52')]=_0x151503;return _0x2bc67a;});}})['then'](respondWithFilteredResult(_0x4b5e01,_0x36c157))['catch'](handleError(_0x4b5e01,null));};exports['addApplications']=function(_0x44232c,_0x147ed4){var _0x295ff6=_0x44232c['params']['id'];var _0x1be69c=_0x44232c[_0x02e0('0x5e')];var _0x1473d4=0xc8;var _0x3ccb84=null;return db[_0x02e0('0x79')][_0x02e0('0x7a')]({'isolationLevel':db[_0x02e0('0x79')][_0x02e0('0x7b')][_0x02e0('0x7c')][_0x02e0('0x7d')]},function(_0x1226d9){return db['FaxAccount'][_0x02e0('0x62')]({'where':{'id':_0x295ff6},'transaction':_0x1226d9})[_0x02e0('0x31')](function(_0x4ba5cd){if(_0x4ba5cd){return db['FaxApplication'][_0x02e0('0x32')]({'where':{'FaxAccountId':_0x295ff6},'transaction':_0x1226d9})[_0x02e0('0x31')](function(){var _0x27f496=_[_0x02e0('0x3d')](_0x1be69c,function(_0x513aff){_0x513aff[_0x02e0('0x68')]=_0x295ff6;return _0x513aff;});return db['FaxApplication'][_0x02e0('0x7e')](_0x27f496,{'transaction':_0x1226d9});});}else{_0x1473d4=0x194;_0x3ccb84=[];}});})['then'](function(){if(_0x1473d4!==0x194){return db[_0x02e0('0x7f')][_0x02e0('0x80')]({'where':{'FaxAccountId':_0x295ff6},'order':_0x02e0('0x81')})[_0x02e0('0x31')](function(_0x3b8e5c){_0x3ccb84=_0x3b8e5c;});}})[_0x02e0('0x25')](function(_0xac7576){_0x1473d4=0x1f4;logger[_0x02e0('0x22')](_0xac7576[_0x02e0('0x37')]);if(_0xac7576[_0x02e0('0x38')]){delete _0xac7576[_0x02e0('0x38')];}_0x3ccb84=_0xac7576;})[_0x02e0('0x82')](function(){if(_0x3ccb84===null){_0x147ed4[_0x02e0('0x26')](_0x1473d4);}else{if(_0x1473d4===0x1f4){_0x147ed4[_0x02e0('0x27')](_0x1473d4)[_0x02e0('0x39')](_0x3ccb84);}else{_0x147ed4['status'](_0x1473d4)[_0x02e0('0x2d')](_0x3ccb84);}}});};exports[_0x02e0('0x83')]=function(_0x39c77b,_0x413524,_0x4a0baf){var _0x11e251={};var _0x1dadda={};var _0xa01ae5;var _0x2f4f76;return db[_0x02e0('0x4f')][_0x02e0('0x62')]({'where':{'id':_0x39c77b[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x413524,null))[_0x02e0('0x31')](function(_0x34dbd5){if(_0x34dbd5){_0xa01ae5=_0x34dbd5;_0x1dadda['model']=_[_0x02e0('0x43')](db['FaxApplication']['rawAttributes']);_0x1dadda['query']=_[_0x02e0('0x43')](_0x39c77b[_0x02e0('0x42')]);_0x1dadda[_0x02e0('0x44')]=_[_0x02e0('0x55')](_0x1dadda[_0x02e0('0x41')],_0x1dadda['query']);_0x11e251[_0x02e0('0x46')]=_[_0x02e0('0x55')](_0x1dadda['model'],qs[_0x02e0('0x45')](_0x39c77b[_0x02e0('0x42')][_0x02e0('0x45')]));_0x11e251[_0x02e0('0x46')]=_0x11e251[_0x02e0('0x46')][_0x02e0('0x47')]?_0x11e251[_0x02e0('0x46')]:_0x1dadda[_0x02e0('0x41')];_0x11e251[_0x02e0('0x63')]=qs[_0x02e0('0x49')](_0x39c77b['query'][_0x02e0('0x49')]);_0x11e251['where']=qs[_0x02e0('0x44')](_[_0x02e0('0x4a')](_0x39c77b[_0x02e0('0x42')],_0x1dadda['filters']));if(_0x39c77b[_0x02e0('0x42')][_0x02e0('0x4e')]){_0x11e251[_0x02e0('0x4b')]=_[_0x02e0('0x4c')](_0x11e251['where'],{'$or':_[_0x02e0('0x3d')](_0x11e251['attributes'],function(_0x3ed707){var _0x1394b1={};_0x1394b1[_0x3ed707]={'$like':'%'+_0x39c77b['query'][_0x02e0('0x4e')]+'%'};return _0x1394b1;})});}_0x11e251=_[_0x02e0('0x4c')]({},_0x11e251,_0x39c77b[_0x02e0('0x64')]);return _0xa01ae5[_0x02e0('0x83')](_0x11e251);}})[_0x02e0('0x31')](function(_0xba0b84){if(_0xba0b84){_0x2f4f76=_0xba0b84[_0x02e0('0x47')];if(!_0x39c77b['query']['hasOwnProperty']('nolimit')){_0x11e251[_0x02e0('0x2b')]=qs[_0x02e0('0x2b')](_0x39c77b[_0x02e0('0x42')]['limit']);_0x11e251[_0x02e0('0x28')]=qs[_0x02e0('0x28')](_0x39c77b['query'][_0x02e0('0x28')]);}return _0xa01ae5[_0x02e0('0x83')](_0x11e251);}})['then'](function(_0x17a0a2){if(_0x17a0a2){return _0x17a0a2?{'count':_0x2f4f76,'rows':_0x17a0a2}:null;}})['then'](respondWithResult(_0x413524,null))[_0x02e0('0x25')](handleError(_0x413524,null));};function Extension(_0x3c943f,_0x222699,_0x55aa09,_0x30b863){this[_0x02e0('0x84')]='from-voip-provider';this['exten']=_0x3c943f[_0x02e0('0x85')];this[_0x02e0('0x86')]=_0x30b863;this[_0x02e0('0x3f')]='system';this[_0x02e0('0x87')]='Fax\x20Extension';this[_0x02e0('0x68')]=_0x3c943f['id'];this[_0x02e0('0x81')]=_0x222699;this[_0x02e0('0x88')]=_0x55aa09;}function createExtensionsReciveFax(_0x41b92f){var _0x2ff970=0x1;var _0x440d83=[];_0x440d83[_0x02e0('0x89')](new Extension(_0x41b92f,_0x2ff970,'',_0x02e0('0x8a')));_0x2ff970+=0x1;_0x440d83['push'](new Extension(_0x41b92f,_0x2ff970,_0x02e0('0x8b'),_0x02e0('0x8c')));_0x2ff970+=0x1;for(var _0x2006d5 in _0x41b92f){if(_0x41b92f[_0x02e0('0x48')](_0x2006d5)&&(_0x2006d5==='ecm'||_0x2006d5===_0x02e0('0x85')||_0x2006d5===_0x02e0('0x8d')||_0x2006d5===_0x02e0('0x8e')||_0x2006d5===_0x02e0('0x8f')||_0x2006d5==='maxrate'||_0x2006d5==='minrate'||_0x2006d5===_0x02e0('0x90')||_0x2006d5==='t38timeout')){_0x440d83[_0x02e0('0x89')](new Extension(_0x41b92f,_0x2ff970,_0x02e0('0x91')+_0x2006d5+')='+_0x41b92f[_0x2006d5],_0x02e0('0x8c')));_0x2ff970+=0x1;}}_0x440d83[_0x02e0('0x89')](new Extension(_0x41b92f,_0x2ff970,'6',_0x02e0('0x92')));_0x2ff970+=0x1;_0x440d83[_0x02e0('0x89')](new Extension(_0x41b92f,_0x2ff970,_0x02e0('0x93'),'ReceiveFax'));_0x2ff970=0x0;return _0x440d83;}exports[_0x02e0('0x94')]=function(_0x749dc2,_0x4c9113,_0x247426){var _0x358eea;return db[_0x02e0('0x79')][_0x02e0('0x7a')](function(_0x23a459){return db['FaxAccount'][_0x02e0('0x58')](_0x749dc2[_0x02e0('0x5e')],{'transaction':_0x23a459})[_0x02e0('0x31')](function(_0x1ef230){_0x358eea=_0x1ef230[_0x02e0('0x33')]({'plain':!![]});return db[_0x02e0('0x95')][_0x02e0('0x7e')](createExtensionsReciveFax(_0x358eea),{'transaction':_0x23a459});});})[_0x02e0('0x31')](function(){return _0x358eea;})[_0x02e0('0x31')](respondWithResult(_0x4c9113,null))[_0x02e0('0x25')](handleError(_0x4c9113,null));};exports[_0x02e0('0x96')]=function(_0x3e4d6c,_0x58b27b,_0x10c83e){var _0x482c5e;return db[_0x02e0('0x79')][_0x02e0('0x7a')](function(_0x2d01eb){return db[_0x02e0('0x4f')]['update'](_0x3e4d6c[_0x02e0('0x5e')],{'where':{'id':_0x3e4d6c[_0x02e0('0x5e')]['id']},'transaction':_0x2d01eb})[_0x02e0('0x31')](function(_0x556cf9){return db[_0x02e0('0x95')][_0x02e0('0x32')]({'where':{'FaxAccountId':_0x3e4d6c[_0x02e0('0x5e')]['id']},'transaction':_0x2d01eb})[_0x02e0('0x31')](function(_0x2ca8b6){return db[_0x02e0('0x95')][_0x02e0('0x7e')](createExtensionsReciveFax(_[_0x02e0('0x6d')](_0x3e4d6c[_0x02e0('0x5e')],[_0x02e0('0x97'),'key',_0x02e0('0x98'),_0x02e0('0x99'),_0x02e0('0x9a'),'ListId'])),{'transaction':_0x2d01eb});});});})['then'](function(){return db['FaxAccount'][_0x02e0('0x9b')](_0x3e4d6c[_0x02e0('0x5e')]['id']);})['then'](respondWithResult(_0x58b27b,null))[_0x02e0('0x25')](handleError(_0x58b27b,null));};exports[_0x02e0('0x9c')]=function(_0x19d6f4,_0x12898c,_0x13b4e4){var _0x49d9fa={'raw':!![],'where':{}};var _0x2e91f5={};var _0x4a7c28={'count':0x0,'rows':[]};return db[_0x02e0('0x4f')]['findOne']({'where':{'id':_0x19d6f4[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x12898c,null))[_0x02e0('0x31')](function(_0x445cd7){if(_0x445cd7){_0x2e91f5[_0x02e0('0x41')]=_[_0x02e0('0x43')](db[_0x02e0('0x9d')][_0x02e0('0x3e')]);_0x2e91f5[_0x02e0('0x42')]=_['keys'](_0x19d6f4[_0x02e0('0x42')]);_0x2e91f5[_0x02e0('0x44')]=_['intersection'](_0x2e91f5[_0x02e0('0x41')],_0x2e91f5[_0x02e0('0x42')]);_0x49d9fa[_0x02e0('0x46')]=_[_0x02e0('0x55')](_0x2e91f5[_0x02e0('0x41')],qs[_0x02e0('0x45')](_0x19d6f4[_0x02e0('0x42')][_0x02e0('0x45')]));_0x49d9fa[_0x02e0('0x46')]=_0x49d9fa[_0x02e0('0x46')]['length']?_0x49d9fa['attributes']:_0x2e91f5[_0x02e0('0x41')];if(!_0x19d6f4[_0x02e0('0x42')][_0x02e0('0x48')](_0x02e0('0x9e'))){_0x49d9fa[_0x02e0('0x2b')]=qs['limit'](_0x19d6f4[_0x02e0('0x42')][_0x02e0('0x2b')]);_0x49d9fa[_0x02e0('0x28')]=qs[_0x02e0('0x28')](_0x19d6f4[_0x02e0('0x42')][_0x02e0('0x28')]);}_0x49d9fa[_0x02e0('0x63')]=qs['sort'](_0x19d6f4[_0x02e0('0x42')][_0x02e0('0x49')]);_0x49d9fa[_0x02e0('0x4b')]=qs['filters'](_[_0x02e0('0x4a')](_0x19d6f4[_0x02e0('0x42')],_0x2e91f5[_0x02e0('0x44')]));_0x49d9fa[_0x02e0('0x4b')][_0x02e0('0x68')]=_0x445cd7['id'];if(_0x19d6f4[_0x02e0('0x42')][_0x02e0('0x4e')]){_0x49d9fa[_0x02e0('0x4b')]=_['merge'](_0x49d9fa[_0x02e0('0x4b')],{'$or':_['map'](_0x49d9fa[_0x02e0('0x46')],function(_0xd4cd6b){var _0x2e354b={};_0x2e354b[_0xd4cd6b]={'$like':'%'+_0x19d6f4[_0x02e0('0x42')]['filter']+'%'};return _0x2e354b;})});}if(_0x19d6f4['query'][_0x02e0('0x9f')]){var _0x40e093=_0x19d6f4[_0x02e0('0x42')][_0x02e0('0x9f')][_0x02e0('0xa0')](',');var _0x395cbd={};_0x395cbd[_0x40e093[0x0]]={'$gte':moment(_0x40e093[0x1])[_0x02e0('0xa1')](_0x02e0('0xa2'))};_0x49d9fa[_0x02e0('0x4b')]=_[_0x02e0('0x4c')](_0x49d9fa[_0x02e0('0x4b')],_0x395cbd);}_0x49d9fa=_[_0x02e0('0x4c')]({},_0x49d9fa,_0x19d6f4[_0x02e0('0x64')]);return db[_0x02e0('0x9d')]['count']({'where':_0x49d9fa[_0x02e0('0x4b')]})[_0x02e0('0x31')](function(_0x281f9b){_0x4a7c28[_0x02e0('0x2a')]=_0x281f9b;if(_0x19d6f4[_0x02e0('0x42')]['includeAll']){_0x49d9fa[_0x02e0('0x50')]=[{'all':!![]}];}return db[_0x02e0('0x9d')][_0x02e0('0x51')](_0x49d9fa);})[_0x02e0('0x31')](function(_0x1bc05a){_0x4a7c28[_0x02e0('0x52')]=_0x1bc05a;return _0x4a7c28;});}})[_0x02e0('0x31')](respondWithFilteredResult(_0x12898c,_0x49d9fa))[_0x02e0('0x25')](handleError(_0x12898c,null));};exports[_0x02e0('0x39')]=function(_0x182d51,_0x2b5864,_0x34e256){var _0x5d1775,_0x13a568={},_0xc56d54;if(_0x182d51['body']['to']){_0xc56d54=_0x182d51[_0x02e0('0x5e')]['to'][0x0];}return db[_0x02e0('0x4f')][_0x02e0('0x57')]({'where':{'id':_0x182d51[_0x02e0('0x54')]['id']},'include':[{'model':db[_0x02e0('0xa3')],'as':_0x02e0('0xa4'),'include':[{'model':db[_0x02e0('0x70')],'as':_0x02e0('0xa5'),'where':{'fax':_0xc56d54},'limit':0x1,'order':[['updatedAt',_0x02e0('0xa6')]]}]}]})[_0x02e0('0x31')](handleEntityNotFound(_0x2b5864,null))['then'](function(_0xf59dbf){_0x5d1775=_0xf59dbf;if(_0x182d51[_0x02e0('0x5e')][_0x02e0('0xa7')]&&_0x182d51[_0x02e0('0x5e')][_0x02e0('0xa7')][_0x02e0('0x47')]){for(var _0x42090b=0x0;_0x42090b<_0x182d51[_0x02e0('0x5e')][_0x02e0('0xa7')][_0x02e0('0x47')];_0x42090b+=0x1){_0x182d51[_0x02e0('0x5e')][_0x02e0('0xa7')][_0x42090b]={'filename':_0x182d51['body'][_0x02e0('0xa7')][_0x42090b]['name'],'id':_0x182d51['body']['attachments'][_0x42090b]['id'],'path':path[_0x02e0('0xa8')](config[_0x02e0('0xa9')],_0x02e0('0xaa'),_0x182d51['body'][_0x02e0('0xa7')][_0x42090b][_0x02e0('0xab')])};}}return respondWithRpcPromise(_0x02e0('0xac'),'CheckAfterSend',{'FaxAccountId':_[_0x02e0('0xad')](_0x182d51[_0x02e0('0x54')]['id'])?undefined:_0x182d51[_0x02e0('0x54')]['id'],'path':_['isNil'](_0x182d51[_0x02e0('0x5e')][_0x02e0('0xa7')][0x0][_0x02e0('0x7')])?undefined:_0x182d51['body']['attachments'][0x0][_0x02e0('0x7')],'fax':_[_0x02e0('0xad')](_0x182d51[_0x02e0('0x5e')]['to'][0x0])?undefined:_0x182d51[_0x02e0('0x5e')]['to'][0x0]},client9002);})[_0x02e0('0x31')](function(){if(_0x5d1775){if(_['isNil'](_0x182d51[_0x02e0('0x5e')]['from'])){_0x182d51['body']['from']=util[_0x02e0('0xa1')](_0x02e0('0xae'),_0x5d1775[_0x02e0('0x38')],_0x5d1775[_0x02e0('0xaf')]);}if(_0x5d1775['List']){if(_0x5d1775['List'][_0x02e0('0xa5')]['length']){return _0x5d1775[_0x02e0('0xa4')]['Contacts'][0x0];}else{return db['CmContact'][_0x02e0('0x58')](_[_0x02e0('0x18')](_0x182d51['body'],{'firstName':_0x182d51[_0x02e0('0x5e')]['to'][0x0],'phone':_0x182d51[_0x02e0('0x5e')]['to'][0x0],'fax':_0x182d51[_0x02e0('0x5e')]['to'][0x0],'ListId':_0x5d1775[_0x02e0('0xb0')]}));}}else{throw new Error(_0x02e0('0xb1'));}}else{throw new Error(_0x02e0('0xb2'));}})[_0x02e0('0x31')](function(_0xf4d141){if(_0xf4d141){return db[_0x02e0('0x6f')]['find']({'where':{'ContactId':_0xf4d141['id'],'closed':![],'FaxAccountId':_0x5d1775['id']}})[_0x02e0('0x31')](function(_0xa36996){if(_0xa36996){return[_0xa36996,![]];}return db['FaxInteraction']['create']({'UserId':_0x182d51[_0x02e0('0x59')]['id'],'ContactId':_0xf4d141['id'],'FaxAccountId':_0x5d1775['id'],'fax':_0x182d51[_0x02e0('0x5e')]['to'][0x0],'firstMsgDirection':_0x02e0('0xb3'),'Messages':[_[_0x02e0('0x4c')](_0x182d51[_0x02e0('0x5e')],{'read':![],'body':_0x182d51[_0x02e0('0x5e')][_0x02e0('0xa7')][0x0][_0x02e0('0xb4')],'FaxAccountId':_0x5d1775['id'],'UserId':_0x182d51[_0x02e0('0x59')]['id'],'ContactId':_0xf4d141['id'],'AttachmentId':_0x182d51[_0x02e0('0x5e')]['attachments'][0x0]['id']})]},{'include':[{'model':db[_0x02e0('0x9d')],'as':_0x02e0('0xb5')}]})[_0x02e0('0x31')](function(_0x7e8f5){return[_0x7e8f5,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})['spread'](function(_0x475985,_0xd7aba){if(_0xd7aba){return _0x475985;}return db[_0x02e0('0x9d')]['create']({'direction':_0x02e0('0xb3'),'read':![],'body':_0x182d51['body'][_0x02e0('0xa7')][0x0][_0x02e0('0xb4')],'FaxAccountId':_0x5d1775['id'],'FaxInteractionId':_0x475985['id'],'UserId':_0x182d51['user']['id'],'ContactId':_0x475985[_0x02e0('0xb6')],'AttachmentId':_0x182d51['body']['attachments'][0x0]['id']})['then'](function(_0x17d7cf){_0x475985[_0x02e0('0xb7')][_0x02e0('0xb5')]=[];_0x475985[_0x02e0('0xb7')][_0x02e0('0xb5')][_0x02e0('0x89')](_0x17d7cf[_0x02e0('0xb7')]);return _0x475985;});})[_0x02e0('0x31')](function(_0x2bafa3){respondWithRpcPromise(_0x02e0('0xb8'),_0x02e0('0xb8'),{'FaxAccountId':_[_0x02e0('0xad')](_0x182d51[_0x02e0('0x54')]['id'])?undefined:_0x182d51[_0x02e0('0x54')]['id'],'path':_[_0x02e0('0xad')](_0x182d51[_0x02e0('0x5e')][_0x02e0('0xa7')][0x0][_0x02e0('0x7')])?undefined:_0x182d51[_0x02e0('0x5e')]['attachments'][0x0]['path'],'fax':_[_0x02e0('0xad')](_0x182d51[_0x02e0('0x5e')]['to'][0x0])?undefined:_0x182d51[_0x02e0('0x5e')]['to'][0x0],'AttachmentId':_0x182d51['body'][_0x02e0('0xa7')][0x0]['id']},client9002)[_0x02e0('0x31')](function(_0x58d782){logger[_0x02e0('0x24')](_0x02e0('0xb9'),_0x58d782);})[_0x02e0('0x25')](function(_0x3e9b84){logger[_0x02e0('0x24')]('SendFaxRpc,\x20%s',_0x3e9b84);});return _0x2bafa3;})['then'](respondWithResult(_0x2b5864,null))[_0x02e0('0x25')](handleError(_0x2b5864,null));};exports[_0x02e0('0xba')]=function(_0x52803a,_0x4937a3,_0x405c94){return db[_0x02e0('0x4f')][_0x02e0('0x57')]({'where':{'id':_0x52803a[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x4937a3,null))[_0x02e0('0x31')](function(_0x3b62f0){if(_0x3b62f0){return _0x3b62f0[_0x02e0('0xba')](_0x52803a[_0x02e0('0x5e')]['ids'],_[_0x02e0('0x6d')](_0x52803a[_0x02e0('0x5e')],['ids','id'])||{})['spread'](function(_0x41ba2e){for(var _0x1f01ec=0x0;_0x1f01ec<_0x52803a[_0x02e0('0x5e')]['ids'][_0x02e0('0x47')];_0x1f01ec+=0x1){socket['emit'](_0x02e0('0xbb'),{'UserId':Number(_0x52803a[_0x02e0('0x5e')]['ids'][_0x1f01ec]),'FaxAccountId':Number(_0x52803a[_0x02e0('0x54')]['id'])});}return _0x41ba2e;});}})['then'](respondWithResult(_0x4937a3,null))[_0x02e0('0x25')](handleError(_0x4937a3,null));};exports[_0x02e0('0xbc')]=function(_0x14685b,_0x381b44,_0x29e8ba){return db[_0x02e0('0x4f')][_0x02e0('0x57')]({'where':{'id':_0x14685b[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x381b44,null))[_0x02e0('0x31')](function(_0x25a39d){if(_0x25a39d){return _0x25a39d[_0x02e0('0xbc')](_0x14685b[_0x02e0('0x42')][_0x02e0('0x66')])['then'](function(){if(_[_0x02e0('0xbd')](_0x14685b['query'][_0x02e0('0x66')])){for(var _0x41ca59=0x0;_0x41ca59<_0x14685b[_0x02e0('0x42')][_0x02e0('0x66')][_0x02e0('0x47')];_0x41ca59+=0x1){socket[_0x02e0('0xbe')](_0x02e0('0xbf'),{'UserId':Number(_0x14685b['query'][_0x02e0('0x66')][_0x41ca59]),'FaxAccountId':Number(_0x14685b[_0x02e0('0x54')]['id'])});}}else{socket[_0x02e0('0xbe')](_0x02e0('0xbf'),{'UserId':Number(_0x14685b[_0x02e0('0x42')][_0x02e0('0x66')]),'FaxAccountId':Number(_0x14685b[_0x02e0('0x54')]['id'])});}});}})['then'](respondWithStatusCode(_0x381b44,null))['catch'](handleError(_0x381b44,null));};exports[_0x02e0('0xc0')]=function(_0x3518f6,_0x3264df,_0x559fcd){var _0x5ebd4f={};var _0x2890b1={};var _0x5d9b1d;var _0x533404;return db[_0x02e0('0x4f')]['findOne']({'where':{'id':_0x3518f6[_0x02e0('0x54')]['id']}})[_0x02e0('0x31')](handleEntityNotFound(_0x3264df,null))[_0x02e0('0x31')](function(_0x2d56ae){if(_0x2d56ae){_0x5d9b1d=_0x2d56ae;_0x2890b1[_0x02e0('0x41')]=_[_0x02e0('0x43')](db[_0x02e0('0x72')][_0x02e0('0x3e')]);_0x2890b1['query']=_[_0x02e0('0x43')](_0x3518f6[_0x02e0('0x42')]);_0x2890b1[_0x02e0('0x44')]=_[_0x02e0('0x55')](_0x2890b1[_0x02e0('0x41')],_0x2890b1[_0x02e0('0x42')]);_0x5ebd4f[_0x02e0('0x46')]=_['intersection'](_0x2890b1[_0x02e0('0x41')],qs[_0x02e0('0x45')](_0x3518f6[_0x02e0('0x42')][_0x02e0('0x45')]));_0x5ebd4f[_0x02e0('0x46')]=_0x5ebd4f[_0x02e0('0x46')][_0x02e0('0x47')]?_0x5ebd4f[_0x02e0('0x46')]:_0x2890b1['model'];_0x5ebd4f['order']=qs[_0x02e0('0x49')](_0x3518f6[_0x02e0('0x42')][_0x02e0('0x49')]);_0x5ebd4f['where']=qs[_0x02e0('0x44')](_[_0x02e0('0x4a')](_0x3518f6['query'],_0x2890b1[_0x02e0('0x44')]));if(_0x3518f6['query']['filter']){_0x5ebd4f[_0x02e0('0x4b')]=_['merge'](_0x5ebd4f[_0x02e0('0x4b')],{'$or':_[_0x02e0('0x3d')](_0x5ebd4f['attributes'],function(_0x40bf59){var _0x3824aa={};_0x3824aa[_0x40bf59]={'$like':'%'+_0x3518f6[_0x02e0('0x42')][_0x02e0('0x4e')]+'%'};return _0x3824aa;})});}_0x5ebd4f=_['merge']({},_0x5ebd4f,_0x3518f6[_0x02e0('0x64')]);return _0x5d9b1d['getAgents'](_0x5ebd4f);}})[_0x02e0('0x31')](function(_0x302bdb){if(_0x302bdb){_0x533404=_0x302bdb['length'];if(!_0x3518f6[_0x02e0('0x42')]['hasOwnProperty']('nolimit')){_0x5ebd4f[_0x02e0('0x2b')]=qs[_0x02e0('0x2b')](_0x3518f6[_0x02e0('0x42')]['limit']);_0x5ebd4f[_0x02e0('0x28')]=qs[_0x02e0('0x28')](_0x3518f6[_0x02e0('0x42')][_0x02e0('0x28')]);}return _0x5d9b1d['getAgents'](_0x5ebd4f);}})[_0x02e0('0x31')](function(_0x22a353){if(_0x22a353){return _0x22a353?{'count':_0x533404,'rows':_0x22a353}:null;}})[_0x02e0('0x31')](respondWithResult(_0x3264df,null))[_0x02e0('0x25')](handleError(_0x3264df,null));};
\ No newline at end of file