Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index 8b37dc9..29c96d6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xde36=['format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','Contacts','DESC','attachments','join','server/files/attachments','basename','CheckAfterSend','isNil','path','from','\x22%s\x22\x20<%s>','fax','List\x20not\x20found','out','Contact\x20not\x20found','spread','filename','ContactId','dataValues','Messages','SendFax','SendFaxRpc,\x20%s','addAgents','emit','isArray','userFaxAccount:remove','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','lodash','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','defaults','localhost','socket.io-emitter','redis','register','jayson/promise','client','http','request','info','FaxAccount,\x20%s,\x20%s','request\x20sent','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','update','destroy','then','get','FaxAccounts','UserProfileResource','end','name','send','index','Pause','mandatoryDispositionPause','map','FaxAccount','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','filter','where','merge','type','VIRTUAL','options','includeAll','findAll','rows','show','params','length','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','FaxAccountId','getDispositions','Disposition','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','findOne','removeAnswers','addInteraction','omit','getInteractions','FaxInteraction','pick','CmContact','User','fullname','internal','Tag','Tags','color','tag','addApplications','transaction','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','FaxApplication','bulkCreate','findAndCountAll','priority','stack','finally','getApplications','context','from-voip-provider','exten','localstationid','app','Fax\x20Extension','appdata','push','Answer','Set','ecm','gateway','faxdetect','headerinfo','minrate','modem','t38timeout','FAXOPT(','Wait','VoiceExtension','updateAccountApplications','tech','createdAt','TrunkId','ListId','findById','getMessages','FaxMessage','$gte','split'];(function(_0x55960e,_0x4f4f80){var _0x1b567b=function(_0x123d7f){while(--_0x123d7f){_0x55960e['push'](_0x55960e['shift']());}};_0x1b567b(++_0x4f4f80);}(_0xde36,0x1af));var _0x6de3=function(_0x20f358,_0x44d78b){_0x20f358=_0x20f358-0x0;var _0x46c51c=_0xde36[_0x20f358];return _0x46c51c;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x6de3('0x0'));var zipdir=require(_0x6de3('0x1'));var jsonpatch=require(_0x6de3('0x2'));var rp=require(_0x6de3('0x3'));var moment=require(_0x6de3('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x6de3('0x5'));var util=require(_0x6de3('0x6'));var path=require('path');var sox=require(_0x6de3('0x7'));var csv=require(_0x6de3('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x6de3('0x9'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x6de3('0xa'));var toCsv=require(_0x6de3('0x8'));var querystring=require(_0x6de3('0xb'));var Papa=require(_0x6de3('0xc'));var Redis=require(_0x6de3('0xd'));var authService=require(_0x6de3('0xe'));var qs=require(_0x6de3('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6de3('0x10'));var logger=require(_0x6de3('0x11'))('api');var utils=require(_0x6de3('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x6de3('0x13'))['db'];config['redis']=_[_0x6de3('0x14')](config['redis'],{'host':_0x6de3('0x15'),'port':0x18eb});var socket=require(_0x6de3('0x16'))(new Redis(config[_0x6de3('0x17')]));require('./faxAccount.socket')[_0x6de3('0x18')](socket);var jayson=require(_0x6de3('0x19'));var client=jayson[_0x6de3('0x1a')][_0x6de3('0x1b')]({'port':0x232c});var client9002=jayson[_0x6de3('0x1a')][_0x6de3('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0xeb2535,_0x370da1,_0x59eeab,_0x4f450a){return new BPromise(function(_0x104828,_0x1c2b8b){var _0x51ef88=_0x4f450a||client;return _0x51ef88[_0x6de3('0x1c')](_0xeb2535,_0x59eeab)['then'](function(_0x5e1a32){logger[_0x6de3('0x1d')](_0x6de3('0x1e'),_0x370da1,_0x6de3('0x1f'));logger['debug'](_0x6de3('0x20'),_0x370da1,_0x6de3('0x1f'),JSON[_0x6de3('0x21')](_0x5e1a32));if(_0x5e1a32['error']){if(_0x5e1a32[_0x6de3('0x22')][_0x6de3('0x23')]===0x1f4){logger[_0x6de3('0x22')]('FaxAccount,\x20%s,\x20%s',_0x370da1,_0x5e1a32[_0x6de3('0x22')]['message']);return _0x1c2b8b(_0x5e1a32[_0x6de3('0x22')][_0x6de3('0x24')]);}logger['error']('FaxAccount,\x20%s,\x20%s',_0x370da1,_0x5e1a32[_0x6de3('0x22')][_0x6de3('0x24')]);return _0x104828(_0x5e1a32[_0x6de3('0x22')][_0x6de3('0x24')]);}else{logger[_0x6de3('0x1d')]('FaxAccount,\x20%s,\x20%s',_0x370da1,_0x6de3('0x1f'));_0x104828(_0x5e1a32[_0x6de3('0x25')][_0x6de3('0x24')]);}})[_0x6de3('0x26')](function(_0x3f6d60){logger[_0x6de3('0x22')]('FaxAccount,\x20%s,\x20%s',_0x370da1,_0x3f6d60);_0x1c2b8b(_0x3f6d60);});});}function respondWithStatusCode(_0x3a93a2,_0x1bd760){_0x1bd760=_0x1bd760||0xcc;return function(_0x4be751){if(_0x4be751){return _0x3a93a2[_0x6de3('0x27')](_0x1bd760);}return _0x3a93a2[_0x6de3('0x28')](_0x1bd760)['end']();};}function respondWithResult(_0x5208f9,_0x3c7f1f){_0x3c7f1f=_0x3c7f1f||0xc8;return function(_0x5a43dd){if(_0x5a43dd){return _0x5208f9[_0x6de3('0x28')](_0x3c7f1f)['json'](_0x5a43dd);}};}function respondWithFilteredResult(_0x1d84a5,_0x1fdada){return function(_0x1c0788){if(_0x1c0788){var _0x313b52=typeof _0x1fdada[_0x6de3('0x29')]===_0x6de3('0x2a')&&typeof _0x1fdada[_0x6de3('0x2b')]===_0x6de3('0x2a');var _0xab3551=_0x1c0788[_0x6de3('0x2c')];var _0x5a5663=_0x313b52?0x0:_0x1fdada['offset'];var _0x507250=_0x313b52?_0x1c0788[_0x6de3('0x2c')]:_0x1fdada[_0x6de3('0x29')]+_0x1fdada[_0x6de3('0x2b')];var _0x1b5265;if(_0x507250>=_0xab3551){_0x507250=_0xab3551;_0x1b5265=0xc8;}else{_0x1b5265=0xce;}_0x1d84a5[_0x6de3('0x28')](_0x1b5265);return _0x1d84a5[_0x6de3('0x2d')](_0x6de3('0x2e'),_0x5a5663+'-'+_0x507250+'/'+_0xab3551)[_0x6de3('0x2f')](_0x1c0788);}return null;};}function patchUpdates(_0x4b4464){return function(_0x276813){try{jsonpatch[_0x6de3('0x30')](_0x276813,_0x4b4464,!![]);}catch(_0x3883ab){return BPromise[_0x6de3('0x31')](_0x3883ab);}return _0x276813[_0x6de3('0x32')]();};}function saveUpdates(_0x365d93,_0x2391aa){return function(_0x338bbd){if(_0x338bbd){return _0x338bbd[_0x6de3('0x33')](_0x365d93)['then'](function(_0x4d9abb){return _0x4d9abb;});}return null;};}function removeEntity(_0x425a4f,_0x4320fb){return function(_0x131a42){if(_0x131a42){return _0x131a42[_0x6de3('0x34')]()[_0x6de3('0x35')](function(){var _0xfddf74=_0x131a42[_0x6de3('0x36')]({'plain':!![]});var _0x13fa74=_0x6de3('0x37');return db[_0x6de3('0x38')][_0x6de3('0x34')]({'where':{'type':_0x13fa74,'resourceId':_0xfddf74['id']}})[_0x6de3('0x35')](function(){return _0x131a42;});})[_0x6de3('0x35')](function(){_0x425a4f[_0x6de3('0x28')](0xcc)[_0x6de3('0x39')]();});}};}function handleEntityNotFound(_0x3bab5d,_0x4a8598){return function(_0x45a9b9){if(!_0x45a9b9){_0x3bab5d['sendStatus'](0x194);}return _0x45a9b9;};}function handleError(_0x35b7e3,_0x16bcd5){_0x16bcd5=_0x16bcd5||0x1f4;return function(_0x5e13ea){logger[_0x6de3('0x22')](_0x5e13ea['stack']);if(_0x5e13ea[_0x6de3('0x3a')]){delete _0x5e13ea['name'];}_0x35b7e3['status'](_0x16bcd5)[_0x6de3('0x3b')](_0x5e13ea);};}exports[_0x6de3('0x3c')]=function(_0x5ee15c,_0x2580c4){var _0x110108={'include':[{'model':db[_0x6de3('0x3d')],'as':_0x6de3('0x3e')}]},_0x539e85={},_0x458561={'count':0x0,'rows':[]};var _0x2596ab=_[_0x6de3('0x3f')](db[_0x6de3('0x40')][_0x6de3('0x41')],function(_0x2fa3a4){return{'name':_0x2fa3a4[_0x6de3('0x42')],'type':_0x2fa3a4['type'][_0x6de3('0x43')]};});_0x539e85[_0x6de3('0x44')]=_[_0x6de3('0x3f')](_0x2596ab,_0x6de3('0x3a'));_0x539e85[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x5ee15c['query']);_0x539e85[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x539e85[_0x6de3('0x44')],_0x539e85['query']);_0x110108[_0x6de3('0x49')]=_[_0x6de3('0x48')](_0x539e85[_0x6de3('0x44')],qs['fields'](_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x110108[_0x6de3('0x49')]=_0x110108[_0x6de3('0x49')]['length']?_0x110108[_0x6de3('0x49')]:_0x539e85[_0x6de3('0x44')];if(!_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x110108['limit']=qs['limit'](_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x2b')]);_0x110108['offset']=qs[_0x6de3('0x29')](_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x29')]);}_0x110108[_0x6de3('0x4d')]=qs[_0x6de3('0x4e')](_0x5ee15c['query'][_0x6de3('0x4e')]);_0x110108['where']=qs['filters'](_['pick'](_0x5ee15c[_0x6de3('0x45')],_0x539e85[_0x6de3('0x47')]),_0x2596ab);if(_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x4f')]){_0x110108[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x110108[_0x6de3('0x50')],{'$or':_[_0x6de3('0x3f')](_0x2596ab,function(_0x576a81){if(_0x576a81[_0x6de3('0x52')]!==_0x6de3('0x53')){var _0x5a6911={};_0x5a6911[_0x576a81[_0x6de3('0x3a')]]={'$like':'%'+_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x5a6911;}})});}_0x110108=_['merge']({},_0x110108,_0x5ee15c[_0x6de3('0x54')]);var _0x5d1fd9={'where':_0x110108[_0x6de3('0x50')]};return db[_0x6de3('0x40')][_0x6de3('0x2c')](_0x5d1fd9)['then'](function(_0x42b56c){_0x458561['count']=_0x42b56c;if(_0x5ee15c[_0x6de3('0x45')][_0x6de3('0x55')]){_0x110108['include']=[{'all':!![]}];}return db['FaxAccount'][_0x6de3('0x56')](_0x110108);})[_0x6de3('0x35')](function(_0x4394fb){_0x458561[_0x6de3('0x57')]=_0x4394fb;return _0x458561;})['then'](respondWithFilteredResult(_0x2580c4,_0x110108))[_0x6de3('0x26')](handleError(_0x2580c4,null));};exports[_0x6de3('0x58')]=function(_0x45a34c,_0x5ad112){var _0xeba343={'raw':![],'where':{'id':_0x45a34c[_0x6de3('0x59')]['id']},'include':[{'model':db[_0x6de3('0x3d')],'as':_0x6de3('0x3e')}]},_0x4bd081={};_0x4bd081[_0x6de3('0x44')]=_[_0x6de3('0x46')](db[_0x6de3('0x40')]['rawAttributes']);_0x4bd081[_0x6de3('0x45')]=_['keys'](_0x45a34c['query']);_0x4bd081[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x4bd081[_0x6de3('0x44')],_0x4bd081[_0x6de3('0x45')]);_0xeba343[_0x6de3('0x49')]=_[_0x6de3('0x48')](_0x4bd081[_0x6de3('0x44')],qs['fields'](_0x45a34c[_0x6de3('0x45')][_0x6de3('0x4a')]));_0xeba343[_0x6de3('0x49')]=_0xeba343['attributes'][_0x6de3('0x5a')]?_0xeba343[_0x6de3('0x49')]:_0x4bd081[_0x6de3('0x44')];if(_0x45a34c['query'][_0x6de3('0x55')]){_0xeba343[_0x6de3('0x5b')]=[{'all':!![]}];}_0xeba343=_[_0x6de3('0x51')]({},_0xeba343,_0x45a34c[_0x6de3('0x54')]);return db[_0x6de3('0x40')][_0x6de3('0x5c')](_0xeba343)['then'](handleEntityNotFound(_0x5ad112,null))['then'](respondWithResult(_0x5ad112,null))[_0x6de3('0x26')](handleError(_0x5ad112,null));};exports['create']=function(_0x3ffdd6,_0x573dc8){return db[_0x6de3('0x40')][_0x6de3('0x5d')](_0x3ffdd6[_0x6de3('0x5e')],{})['then'](function(_0x46167c){var _0x6317d8=_0x3ffdd6[_0x6de3('0x5f')][_0x6de3('0x36')]({'plain':!![]});if(!_0x6317d8)throw new Error(_0x6de3('0x60'));if(_0x6317d8[_0x6de3('0x61')]===_0x6de3('0x5f')){var _0x75f614=_0x46167c['get']({'plain':!![]});var _0x21d365=_0x6de3('0x37');return db['UserProfileSection']['find']({'where':{'name':_0x21d365,'userProfileId':_0x6317d8[_0x6de3('0x62')]},'raw':!![]})[_0x6de3('0x35')](function(_0x2001e7){if(_0x2001e7&&_0x2001e7[_0x6de3('0x63')]===0x0){return db[_0x6de3('0x38')][_0x6de3('0x5d')]({'name':_0x75f614[_0x6de3('0x3a')],'resourceId':_0x75f614['id'],'type':_0x2001e7[_0x6de3('0x3a')],'sectionId':_0x2001e7['id']},{})[_0x6de3('0x35')](function(){return _0x46167c;});}else{return _0x46167c;}})[_0x6de3('0x26')](function(_0xfb1bb6){logger[_0x6de3('0x22')](_0x6de3('0x64'),_0xfb1bb6);throw _0xfb1bb6;});}return _0x46167c;})[_0x6de3('0x35')](respondWithResult(_0x573dc8,0xc9))[_0x6de3('0x26')](handleError(_0x573dc8,null));};exports[_0x6de3('0x33')]=function(_0x243465,_0x15de53){if(_0x243465[_0x6de3('0x5e')]['id']){delete _0x243465['body']['id'];}return db['FaxAccount'][_0x6de3('0x5c')]({'where':{'id':_0x243465['params']['id']},'include':[{'model':db[_0x6de3('0x3d')],'as':_0x6de3('0x3e')}]})[_0x6de3('0x35')](handleEntityNotFound(_0x15de53,null))[_0x6de3('0x35')](saveUpdates(_0x243465[_0x6de3('0x5e')],null))[_0x6de3('0x35')](respondWithResult(_0x15de53,null))[_0x6de3('0x26')](handleError(_0x15de53,null));};exports[_0x6de3('0x34')]=function(_0x4fda25,_0x3a447a){return db['FaxAccount']['find']({'where':{'id':_0x4fda25['params']['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x3a447a,null))[_0x6de3('0x35')](removeEntity(_0x3a447a,null))[_0x6de3('0x26')](handleError(_0x3a447a,null));};exports[_0x6de3('0x65')]=function(_0x49a856,_0x196748){return db[_0x6de3('0x40')][_0x6de3('0x65')]()['then'](respondWithResult(_0x196748,null))[_0x6de3('0x26')](handleError(_0x196748,null));};exports[_0x6de3('0x66')]=function(_0x55f641,_0x4413b7,_0x1e593d){if(_0x55f641[_0x6de3('0x5e')]['id']){delete _0x55f641['body']['id'];}return db[_0x6de3('0x40')][_0x6de3('0x5c')]({'where':{'id':_0x55f641[_0x6de3('0x59')]['id']}})['then'](handleEntityNotFound(_0x4413b7,null))[_0x6de3('0x35')](function(_0x2711e7){if(_0x2711e7){_0x55f641[_0x6de3('0x5e')][_0x6de3('0x67')]=_0x2711e7['id'];return db['Disposition'][_0x6de3('0x5d')](_0x55f641[_0x6de3('0x5e')]);}})[_0x6de3('0x35')](respondWithResult(_0x4413b7,null))['catch'](handleError(_0x4413b7,null));};exports[_0x6de3('0x68')]=function(_0x2fa9b1,_0x1622ee,_0x126568){var _0x34443a={'raw':![],'where':{}};var _0x4bc7dc={};var _0x10a4d9={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x2fa9b1[_0x6de3('0x59')]['id']}})['then'](handleEntityNotFound(_0x1622ee,null))[_0x6de3('0x35')](function(_0x251135){if(_0x251135){_0x4bc7dc[_0x6de3('0x44')]=_[_0x6de3('0x46')](db[_0x6de3('0x69')][_0x6de3('0x41')]);_0x4bc7dc[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x2fa9b1[_0x6de3('0x45')]);_0x4bc7dc['filters']=_[_0x6de3('0x48')](_0x4bc7dc[_0x6de3('0x44')],_0x4bc7dc['query']);_0x34443a['attributes']=_[_0x6de3('0x48')](_0x4bc7dc[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0x2fa9b1[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x34443a[_0x6de3('0x49')]=_0x34443a[_0x6de3('0x49')][_0x6de3('0x5a')]?_0x34443a['attributes']:_0x4bc7dc[_0x6de3('0x44')];if(!_0x2fa9b1['query']['hasOwnProperty'](_0x6de3('0x4c'))){_0x34443a[_0x6de3('0x2b')]=qs[_0x6de3('0x2b')](_0x2fa9b1[_0x6de3('0x45')][_0x6de3('0x2b')]);_0x34443a[_0x6de3('0x29')]=qs[_0x6de3('0x29')](_0x2fa9b1[_0x6de3('0x45')]['offset']);}_0x34443a['order']=qs[_0x6de3('0x4e')](_0x2fa9b1[_0x6de3('0x45')][_0x6de3('0x4e')]);_0x34443a[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_['pick'](_0x2fa9b1[_0x6de3('0x45')],_0x4bc7dc[_0x6de3('0x47')]));_0x34443a[_0x6de3('0x50')][_0x6de3('0x67')]=_0x251135['id'];if(_0x2fa9b1['query'][_0x6de3('0x4f')]){_0x34443a[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x34443a['where'],{'$or':_[_0x6de3('0x3f')](_0x34443a[_0x6de3('0x49')],function(_0x1af9f6){var _0x503a40={};_0x503a40[_0x1af9f6]={'$like':'%'+_0x2fa9b1[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x503a40;})});}_0x34443a=_[_0x6de3('0x51')]({},_0x34443a,_0x2fa9b1[_0x6de3('0x54')]);return db[_0x6de3('0x69')]['count']({'where':_0x34443a['where']})[_0x6de3('0x35')](function(_0xb8e339){_0x10a4d9[_0x6de3('0x2c')]=_0xb8e339;if(_0x2fa9b1['query'][_0x6de3('0x55')]){_0x34443a[_0x6de3('0x5b')]=[{'all':!![]}];}return db[_0x6de3('0x69')]['findAll'](_0x34443a);})[_0x6de3('0x35')](function(_0x30bf67){_0x10a4d9[_0x6de3('0x57')]=_0x30bf67;return _0x10a4d9;});}})[_0x6de3('0x35')](respondWithFilteredResult(_0x1622ee,_0x34443a))['catch'](handleError(_0x1622ee,null));};exports['removeDispositions']=function(_0x153553,_0x19deaf,_0x530f80){return db[_0x6de3('0x40')][_0x6de3('0x5c')]({'where':{'id':_0x153553['params']['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x19deaf,null))[_0x6de3('0x35')](function(_0x107c3b){if(_0x107c3b){return _0x107c3b[_0x6de3('0x6a')](_0x153553[_0x6de3('0x45')][_0x6de3('0x6b')]);}})[_0x6de3('0x35')](respondWithStatusCode(_0x19deaf,null))[_0x6de3('0x26')](handleError(_0x19deaf,null));};exports[_0x6de3('0x6c')]=function(_0x4414e4,_0x2e9f8d,_0x5f5b79){if(_0x4414e4[_0x6de3('0x5e')]['id']){delete _0x4414e4[_0x6de3('0x5e')]['id'];}return db[_0x6de3('0x40')][_0x6de3('0x5c')]({'where':{'id':_0x4414e4[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x2e9f8d,null))[_0x6de3('0x35')](function(_0x3596bc){if(_0x3596bc){_0x4414e4[_0x6de3('0x5e')]['FaxAccountId']=_0x3596bc['id'];return db[_0x6de3('0x6d')][_0x6de3('0x5d')](_0x4414e4[_0x6de3('0x5e')]);}})[_0x6de3('0x35')](respondWithResult(_0x2e9f8d,null))[_0x6de3('0x26')](handleError(_0x2e9f8d,null));};exports[_0x6de3('0x6e')]=function(_0x5de66c,_0x36a098,_0x17fc51){var _0x4cc24d={'raw':![],'where':{}};var _0x2596ba={};var _0x55c417={'count':0x0,'rows':[]};return db[_0x6de3('0x40')][_0x6de3('0x6f')]({'where':{'id':_0x5de66c[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x36a098,null))[_0x6de3('0x35')](function(_0x40ecb9){if(_0x40ecb9){_0x2596ba['model']=_[_0x6de3('0x46')](db[_0x6de3('0x6d')][_0x6de3('0x41')]);_0x2596ba[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x5de66c[_0x6de3('0x45')]);_0x2596ba[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x2596ba[_0x6de3('0x44')],_0x2596ba[_0x6de3('0x45')]);_0x4cc24d['attributes']=_[_0x6de3('0x48')](_0x2596ba[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0x5de66c[_0x6de3('0x45')]['fields']));_0x4cc24d[_0x6de3('0x49')]=_0x4cc24d[_0x6de3('0x49')][_0x6de3('0x5a')]?_0x4cc24d['attributes']:_0x2596ba['model'];if(!_0x5de66c[_0x6de3('0x45')]['hasOwnProperty'](_0x6de3('0x4c'))){_0x4cc24d['limit']=qs[_0x6de3('0x2b')](_0x5de66c[_0x6de3('0x45')][_0x6de3('0x2b')]);_0x4cc24d['offset']=qs['offset'](_0x5de66c[_0x6de3('0x45')][_0x6de3('0x29')]);}_0x4cc24d[_0x6de3('0x4d')]=qs[_0x6de3('0x4e')](_0x5de66c[_0x6de3('0x45')][_0x6de3('0x4e')]);_0x4cc24d[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_['pick'](_0x5de66c['query'],_0x2596ba[_0x6de3('0x47')]));_0x4cc24d[_0x6de3('0x50')][_0x6de3('0x67')]=_0x40ecb9['id'];if(_0x5de66c[_0x6de3('0x45')]['filter']){_0x4cc24d[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x4cc24d[_0x6de3('0x50')],{'$or':_[_0x6de3('0x3f')](_0x4cc24d[_0x6de3('0x49')],function(_0x402efb){var _0x54a4bb={};_0x54a4bb[_0x402efb]={'$like':'%'+_0x5de66c[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x54a4bb;})});}_0x4cc24d=_['merge']({},_0x4cc24d,_0x5de66c[_0x6de3('0x54')]);return db[_0x6de3('0x6d')][_0x6de3('0x2c')]({'where':_0x4cc24d[_0x6de3('0x50')]})[_0x6de3('0x35')](function(_0x55c7e9){_0x55c417['count']=_0x55c7e9;if(_0x5de66c['query']['includeAll']){_0x4cc24d[_0x6de3('0x5b')]=[{'all':!![]}];}return db[_0x6de3('0x6d')][_0x6de3('0x56')](_0x4cc24d);})['then'](function(_0x25fe53){_0x55c417[_0x6de3('0x57')]=_0x25fe53;return _0x55c417;});}})[_0x6de3('0x35')](respondWithFilteredResult(_0x36a098,_0x4cc24d))[_0x6de3('0x26')](handleError(_0x36a098,null));};exports['removeAnswers']=function(_0xd3abae,_0xdf1203,_0x1fe2b1){return db['FaxAccount'][_0x6de3('0x5c')]({'where':{'id':_0xd3abae[_0x6de3('0x59')]['id']}})['then'](handleEntityNotFound(_0xdf1203,null))[_0x6de3('0x35')](function(_0x154498){if(_0x154498){return _0x154498[_0x6de3('0x70')](_0xd3abae[_0x6de3('0x45')][_0x6de3('0x6b')]);}})[_0x6de3('0x35')](respondWithStatusCode(_0xdf1203,null))[_0x6de3('0x26')](handleError(_0xdf1203,null));};exports['addInteraction']=function(_0x3f6127,_0x2b0804,_0x1c5a43){return db['FaxInteraction']['find']({'where':{'id':_0x3f6127['params']['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x2b0804,null))[_0x6de3('0x35')](function(_0x15df38){if(_0x15df38){return _0x15df38[_0x6de3('0x71')](_0x3f6127[_0x6de3('0x5e')]['ids'],_[_0x6de3('0x72')](_0x3f6127[_0x6de3('0x5e')],[_0x6de3('0x6b'),'id'])||{});}})[_0x6de3('0x35')](respondWithResult(_0x2b0804,null))[_0x6de3('0x26')](handleError(_0x2b0804,null));};exports[_0x6de3('0x73')]=function(_0x297bdd,_0x118087,_0x3b1b36){var _0x31d47={'raw':![],'where':{}};var _0x2d42d1={};var _0x2575da={'count':0x0,'rows':[]};return db[_0x6de3('0x40')][_0x6de3('0x6f')]({'where':{'id':_0x297bdd[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x118087,null))[_0x6de3('0x35')](function(_0x5d03ac){if(_0x5d03ac){_0x2d42d1[_0x6de3('0x44')]=_[_0x6de3('0x46')](db[_0x6de3('0x74')][_0x6de3('0x41')]);_0x2d42d1[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x297bdd[_0x6de3('0x45')]);_0x2d42d1[_0x6de3('0x47')]=_['intersection'](_0x2d42d1[_0x6de3('0x44')],_0x2d42d1[_0x6de3('0x45')]);_0x31d47[_0x6de3('0x49')]=_[_0x6de3('0x48')](_0x2d42d1['model'],qs[_0x6de3('0x4a')](_0x297bdd[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x31d47['attributes']=_0x31d47['attributes']['length']?_0x31d47['attributes']:_0x2d42d1[_0x6de3('0x44')];if(!_0x297bdd[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x31d47[_0x6de3('0x2b')]=qs[_0x6de3('0x2b')](_0x297bdd['query'][_0x6de3('0x2b')]);_0x31d47[_0x6de3('0x29')]=qs[_0x6de3('0x29')](_0x297bdd[_0x6de3('0x45')][_0x6de3('0x29')]);}_0x31d47['order']=qs['sort'](_0x297bdd['query'][_0x6de3('0x4e')]);_0x31d47[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_[_0x6de3('0x75')](_0x297bdd['query'],_0x2d42d1[_0x6de3('0x47')]));_0x31d47[_0x6de3('0x50')]['FaxAccountId']=_0x5d03ac['id'];if(_0x297bdd[_0x6de3('0x45')][_0x6de3('0x4f')]){_0x31d47[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x31d47['where'],{'$or':_[_0x6de3('0x3f')](_0x31d47['attributes'],function(_0x2c22f8){var _0x5adad4={};_0x5adad4[_0x2c22f8]={'$like':'%'+_0x297bdd[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x5adad4;})});}_0x31d47=_[_0x6de3('0x51')]({},_0x31d47,_0x297bdd[_0x6de3('0x54')]);return db['FaxInteraction'][_0x6de3('0x2c')]({'where':_0x31d47[_0x6de3('0x50')]})['then'](function(_0x28f402){_0x2575da[_0x6de3('0x2c')]=_0x28f402;if(_0x297bdd[_0x6de3('0x45')]['includeAll']){_0x31d47[_0x6de3('0x5b')]=[{'model':db[_0x6de3('0x76')],'as':'Contact','required':![]},{'model':db[_0x6de3('0x77')],'as':'Owner','attributes':[_0x6de3('0x3a'),_0x6de3('0x78'),_0x6de3('0x79')],'required':![]},{'model':db[_0x6de3('0x7a')],'as':_0x6de3('0x7b'),'attributes':['id','name',_0x6de3('0x7c')],'where':_0x297bdd[_0x6de3('0x45')]['tag']?{'id':_0x297bdd[_0x6de3('0x45')][_0x6de3('0x7d')]}:undefined,'required':_0x297bdd[_0x6de3('0x45')]['tag']?!![]:![]}];}return db[_0x6de3('0x74')][_0x6de3('0x56')](_0x31d47);})[_0x6de3('0x35')](function(_0xa7715b){_0x2575da[_0x6de3('0x57')]=_0xa7715b;return _0x2575da;});}})[_0x6de3('0x35')](respondWithFilteredResult(_0x118087,_0x31d47))[_0x6de3('0x26')](handleError(_0x118087,null));};exports[_0x6de3('0x7e')]=function(_0x486b02,_0x31b9e3){var _0x44f508=_0x486b02[_0x6de3('0x59')]['id'];var _0x37e120=_0x486b02[_0x6de3('0x5e')];var _0xa0afc3=0xc8;var _0xb39dd3=null;return db['sequelize'][_0x6de3('0x7f')]({'isolationLevel':db[_0x6de3('0x80')][_0x6de3('0x81')][_0x6de3('0x82')][_0x6de3('0x83')]},function(_0x3a7def){return db['FaxAccount'][_0x6de3('0x6f')]({'where':{'id':_0x44f508},'transaction':_0x3a7def})[_0x6de3('0x35')](function(_0x47dc77){if(_0x47dc77){return db['FaxApplication'][_0x6de3('0x34')]({'where':{'FaxAccountId':_0x44f508},'transaction':_0x3a7def})['then'](function(){var _0x2c8585=_[_0x6de3('0x3f')](_0x37e120,function(_0x5b9a81){_0x5b9a81[_0x6de3('0x67')]=_0x44f508;return _0x5b9a81;});return db[_0x6de3('0x84')][_0x6de3('0x85')](_0x2c8585,{'transaction':_0x3a7def});});}else{_0xa0afc3=0x194;_0xb39dd3=[];}});})['then'](function(){if(_0xa0afc3!==0x194){return db['FaxApplication'][_0x6de3('0x86')]({'where':{'FaxAccountId':_0x44f508},'order':_0x6de3('0x87')})['then'](function(_0x5259eb){_0xb39dd3=_0x5259eb;});}})[_0x6de3('0x26')](function(_0x3a7664){_0xa0afc3=0x1f4;logger[_0x6de3('0x22')](_0x3a7664[_0x6de3('0x88')]);if(_0x3a7664[_0x6de3('0x3a')]){delete _0x3a7664[_0x6de3('0x3a')];}_0xb39dd3=_0x3a7664;})[_0x6de3('0x89')](function(){if(_0xb39dd3===null){_0x31b9e3[_0x6de3('0x27')](_0xa0afc3);}else{if(_0xa0afc3===0x1f4){_0x31b9e3[_0x6de3('0x28')](_0xa0afc3)['send'](_0xb39dd3);}else{_0x31b9e3[_0x6de3('0x28')](_0xa0afc3)[_0x6de3('0x2f')](_0xb39dd3);}}});};exports['getApplications']=function(_0x4c684c,_0x1ff19e,_0x3ca9b8){var _0x33f42d={};var _0x3b36d6={};var _0x3dfafc;var _0x328a24;return db[_0x6de3('0x40')][_0x6de3('0x6f')]({'where':{'id':_0x4c684c['params']['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x1ff19e,null))[_0x6de3('0x35')](function(_0x2e453c){if(_0x2e453c){_0x3dfafc=_0x2e453c;_0x3b36d6['model']=_[_0x6de3('0x46')](db['FaxApplication'][_0x6de3('0x41')]);_0x3b36d6['query']=_[_0x6de3('0x46')](_0x4c684c['query']);_0x3b36d6[_0x6de3('0x47')]=_['intersection'](_0x3b36d6['model'],_0x3b36d6[_0x6de3('0x45')]);_0x33f42d[_0x6de3('0x49')]=_['intersection'](_0x3b36d6[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0x4c684c[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x33f42d[_0x6de3('0x49')]=_0x33f42d[_0x6de3('0x49')]['length']?_0x33f42d[_0x6de3('0x49')]:_0x3b36d6[_0x6de3('0x44')];_0x33f42d[_0x6de3('0x4d')]=qs[_0x6de3('0x4e')](_0x4c684c[_0x6de3('0x45')][_0x6de3('0x4e')]);_0x33f42d[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_[_0x6de3('0x75')](_0x4c684c[_0x6de3('0x45')],_0x3b36d6[_0x6de3('0x47')]));if(_0x4c684c['query'][_0x6de3('0x4f')]){_0x33f42d[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x33f42d[_0x6de3('0x50')],{'$or':_['map'](_0x33f42d[_0x6de3('0x49')],function(_0x2f2787){var _0x367024={};_0x367024[_0x2f2787]={'$like':'%'+_0x4c684c['query'][_0x6de3('0x4f')]+'%'};return _0x367024;})});}_0x33f42d=_[_0x6de3('0x51')]({},_0x33f42d,_0x4c684c[_0x6de3('0x54')]);return _0x3dfafc[_0x6de3('0x8a')](_0x33f42d);}})['then'](function(_0x2d783a){if(_0x2d783a){_0x328a24=_0x2d783a[_0x6de3('0x5a')];if(!_0x4c684c[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x33f42d[_0x6de3('0x2b')]=qs[_0x6de3('0x2b')](_0x4c684c[_0x6de3('0x45')][_0x6de3('0x2b')]);_0x33f42d[_0x6de3('0x29')]=qs['offset'](_0x4c684c[_0x6de3('0x45')]['offset']);}return _0x3dfafc['getApplications'](_0x33f42d);}})[_0x6de3('0x35')](function(_0x26a46a){if(_0x26a46a){return _0x26a46a?{'count':_0x328a24,'rows':_0x26a46a}:null;}})[_0x6de3('0x35')](respondWithResult(_0x1ff19e,null))[_0x6de3('0x26')](handleError(_0x1ff19e,null));};function Extension(_0x5592dd,_0x7615a7,_0x16e003,_0x4a245b){this[_0x6de3('0x8b')]=_0x6de3('0x8c');this[_0x6de3('0x8d')]=_0x5592dd[_0x6de3('0x8e')];this[_0x6de3('0x8f')]=_0x4a245b;this[_0x6de3('0x52')]='system';this['description']=_0x6de3('0x90');this[_0x6de3('0x67')]=_0x5592dd['id'];this[_0x6de3('0x87')]=_0x7615a7;this[_0x6de3('0x91')]=_0x16e003;}function createExtensionsReciveFax(_0x5edcd6){var _0x4fa89f=0x1;var _0x46002f=[];_0x46002f[_0x6de3('0x92')](new Extension(_0x5edcd6,_0x4fa89f,'',_0x6de3('0x93')));_0x4fa89f+=0x1;_0x46002f[_0x6de3('0x92')](new Extension(_0x5edcd6,_0x4fa89f,'CDR(type)=inbound-fax',_0x6de3('0x94')));_0x4fa89f+=0x1;for(var _0x1c2968 in _0x5edcd6){if(_0x5edcd6[_0x6de3('0x4b')](_0x1c2968)&&(_0x1c2968===_0x6de3('0x95')||_0x1c2968===_0x6de3('0x8e')||_0x1c2968===_0x6de3('0x96')||_0x1c2968===_0x6de3('0x97')||_0x1c2968===_0x6de3('0x98')||_0x1c2968==='maxrate'||_0x1c2968===_0x6de3('0x99')||_0x1c2968===_0x6de3('0x9a')||_0x1c2968===_0x6de3('0x9b'))){_0x46002f['push'](new Extension(_0x5edcd6,_0x4fa89f,_0x6de3('0x9c')+_0x1c2968+')='+_0x5edcd6[_0x1c2968],_0x6de3('0x94')));_0x4fa89f+=0x1;}}_0x46002f['push'](new Extension(_0x5edcd6,_0x4fa89f,'6',_0x6de3('0x9d')));_0x4fa89f+=0x1;_0x46002f[_0x6de3('0x92')](new Extension(_0x5edcd6,_0x4fa89f,'/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'));_0x4fa89f=0x0;return _0x46002f;}exports['addAccountApplications']=function(_0x2b6caf,_0x10eab6,_0x7945e9){var _0x4d79f2;return db[_0x6de3('0x80')][_0x6de3('0x7f')](function(_0x2a6507){return db['FaxAccount'][_0x6de3('0x5d')](_0x2b6caf[_0x6de3('0x5e')],{'transaction':_0x2a6507})[_0x6de3('0x35')](function(_0x27c767){_0x4d79f2=_0x27c767['get']({'plain':!![]});return db[_0x6de3('0x9e')][_0x6de3('0x85')](createExtensionsReciveFax(_0x4d79f2),{'transaction':_0x2a6507});});})[_0x6de3('0x35')](function(){return _0x4d79f2;})[_0x6de3('0x35')](respondWithResult(_0x10eab6,null))[_0x6de3('0x26')](handleError(_0x10eab6,null));};exports[_0x6de3('0x9f')]=function(_0x49ce5f,_0x28787b,_0xa39442){var _0x4f0a84;return db['sequelize'][_0x6de3('0x7f')](function(_0x1a1e12){return db['FaxAccount'][_0x6de3('0x33')](_0x49ce5f['body'],{'where':{'id':_0x49ce5f[_0x6de3('0x5e')]['id']},'transaction':_0x1a1e12})[_0x6de3('0x35')](function(_0x4459b1){return db[_0x6de3('0x9e')][_0x6de3('0x34')]({'where':{'FaxAccountId':_0x49ce5f['body']['id']},'transaction':_0x1a1e12})[_0x6de3('0x35')](function(_0x5246a3){return db['VoiceExtension'][_0x6de3('0x85')](createExtensionsReciveFax(_['omit'](_0x49ce5f[_0x6de3('0x5e')],[_0x6de3('0xa0'),_0x6de3('0x43'),_0x6de3('0xa1'),'updatedAt',_0x6de3('0xa2'),_0x6de3('0xa3')])),{'transaction':_0x1a1e12});});});})['then'](function(){return db[_0x6de3('0x40')][_0x6de3('0xa4')](_0x49ce5f[_0x6de3('0x5e')]['id']);})['then'](respondWithResult(_0x28787b,null))[_0x6de3('0x26')](handleError(_0x28787b,null));};exports[_0x6de3('0xa5')]=function(_0xce9e36,_0x5944b9,_0x34f546){var _0x4e6f46={'raw':!![],'where':{}};var _0x1b202a={};var _0xe4b702={'count':0x0,'rows':[]};return db['FaxAccount'][_0x6de3('0x6f')]({'where':{'id':_0xce9e36[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x5944b9,null))['then'](function(_0x4b0c5d){if(_0x4b0c5d){_0x1b202a[_0x6de3('0x44')]=_['keys'](db[_0x6de3('0xa6')][_0x6de3('0x41')]);_0x1b202a[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0xce9e36[_0x6de3('0x45')]);_0x1b202a[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x1b202a['model'],_0x1b202a[_0x6de3('0x45')]);_0x4e6f46[_0x6de3('0x49')]=_['intersection'](_0x1b202a[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0xce9e36['query']['fields']));_0x4e6f46[_0x6de3('0x49')]=_0x4e6f46[_0x6de3('0x49')][_0x6de3('0x5a')]?_0x4e6f46[_0x6de3('0x49')]:_0x1b202a[_0x6de3('0x44')];if(!_0xce9e36[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x4e6f46[_0x6de3('0x2b')]=qs['limit'](_0xce9e36[_0x6de3('0x45')]['limit']);_0x4e6f46[_0x6de3('0x29')]=qs[_0x6de3('0x29')](_0xce9e36['query'][_0x6de3('0x29')]);}_0x4e6f46[_0x6de3('0x4d')]=qs['sort'](_0xce9e36[_0x6de3('0x45')]['sort']);_0x4e6f46['where']=qs[_0x6de3('0x47')](_['pick'](_0xce9e36[_0x6de3('0x45')],_0x1b202a[_0x6de3('0x47')]));_0x4e6f46[_0x6de3('0x50')][_0x6de3('0x67')]=_0x4b0c5d['id'];if(_0xce9e36['query']['filter']){_0x4e6f46[_0x6de3('0x50')]=_[_0x6de3('0x51')](_0x4e6f46[_0x6de3('0x50')],{'$or':_[_0x6de3('0x3f')](_0x4e6f46[_0x6de3('0x49')],function(_0x1bc472){var _0x5270e1={};_0x5270e1[_0x1bc472]={'$like':'%'+_0xce9e36[_0x6de3('0x45')][_0x6de3('0x4f')]+'%'};return _0x5270e1;})});}if(_0xce9e36[_0x6de3('0x45')][_0x6de3('0xa7')]){var _0x185888=_0xce9e36['query'][_0x6de3('0xa7')][_0x6de3('0xa8')](',');var _0x53af42={};_0x53af42[_0x185888[0x0]]={'$gte':moment(_0x185888[0x1])[_0x6de3('0xa9')](_0x6de3('0xaa'))};_0x4e6f46['where']=_[_0x6de3('0x51')](_0x4e6f46[_0x6de3('0x50')],_0x53af42);}_0x4e6f46=_[_0x6de3('0x51')]({},_0x4e6f46,_0xce9e36[_0x6de3('0x54')]);return db[_0x6de3('0xa6')][_0x6de3('0x2c')]({'where':_0x4e6f46['where']})[_0x6de3('0x35')](function(_0x22fc36){_0xe4b702[_0x6de3('0x2c')]=_0x22fc36;if(_0xce9e36[_0x6de3('0x45')][_0x6de3('0x55')]){_0x4e6f46[_0x6de3('0x5b')]=[{'all':!![]}];}return db[_0x6de3('0xa6')][_0x6de3('0x56')](_0x4e6f46);})[_0x6de3('0x35')](function(_0x4be4fd){_0xe4b702[_0x6de3('0x57')]=_0x4be4fd;return _0xe4b702;});}})[_0x6de3('0x35')](respondWithFilteredResult(_0x5944b9,_0x4e6f46))[_0x6de3('0x26')](handleError(_0x5944b9,null));};exports['send']=function(_0xa470f,_0x4a98c0,_0x2f2a63){var _0x5a52c3,_0x4e74d2={},_0xbb436f;if(_0xa470f['body']['to']){_0xbb436f=_0xa470f[_0x6de3('0x5e')]['to'][0x0];}return db['FaxAccount'][_0x6de3('0x5c')]({'where':{'id':_0xa470f['params']['id']},'include':[{'model':db[_0x6de3('0xab')],'as':_0x6de3('0xac'),'include':[{'model':db['CmContact'],'as':_0x6de3('0xad'),'where':{'fax':_0xbb436f},'limit':0x1,'order':[['updatedAt',_0x6de3('0xae')]]}]}]})[_0x6de3('0x35')](handleEntityNotFound(_0x4a98c0,null))[_0x6de3('0x35')](function(_0x5711cf){_0x5a52c3=_0x5711cf;if(_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')]&&_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][_0x6de3('0x5a')]){for(var _0x4682a1=0x0;_0x4682a1<_0xa470f[_0x6de3('0x5e')]['attachments'][_0x6de3('0x5a')];_0x4682a1+=0x1){_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][_0x4682a1]={'filename':_0xa470f[_0x6de3('0x5e')]['attachments'][_0x4682a1][_0x6de3('0x3a')],'id':_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][_0x4682a1]['id'],'path':path[_0x6de3('0xb0')](config['root'],_0x6de3('0xb1'),_0xa470f['body'][_0x6de3('0xaf')][_0x4682a1][_0x6de3('0xb2')])};}}return respondWithRpcPromise(_0x6de3('0xb3'),_0x6de3('0xb3'),{'FaxAccountId':_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x59')]['id'])?undefined:_0xa470f[_0x6de3('0x59')]['id'],'path':_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0][_0x6de3('0xb5')])?undefined:_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0]['path'],'fax':_[_0x6de3('0xb4')](_0xa470f['body']['to'][0x0])?undefined:_0xa470f['body']['to'][0x0]},client9002);})[_0x6de3('0x35')](function(){if(_0x5a52c3){if(_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x5e')][_0x6de3('0xb6')])){_0xa470f['body'][_0x6de3('0xb6')]=util[_0x6de3('0xa9')](_0x6de3('0xb7'),_0x5a52c3[_0x6de3('0x3a')],_0x5a52c3[_0x6de3('0xb8')]);}if(_0x5a52c3['List']){if(_0x5a52c3['List'][_0x6de3('0xad')][_0x6de3('0x5a')]){return _0x5a52c3['List'][_0x6de3('0xad')][0x0];}else{return db[_0x6de3('0x76')][_0x6de3('0x5d')](_[_0x6de3('0x14')](_0xa470f[_0x6de3('0x5e')],{'firstName':_0xa470f[_0x6de3('0x5e')]['to'][0x0],'phone':_0xa470f['body']['to'][0x0],'fax':_0xa470f[_0x6de3('0x5e')]['to'][0x0],'ListId':_0x5a52c3[_0x6de3('0xa3')]}));}}else{throw new Error(_0x6de3('0xb9'));}}else{throw new Error('Send\x20Fax\x20failed');}})[_0x6de3('0x35')](function(_0x451381){if(_0x451381){return db[_0x6de3('0x74')]['find']({'where':{'ContactId':_0x451381['id'],'closed':![],'FaxAccountId':_0x5a52c3['id']}})[_0x6de3('0x35')](function(_0x27d3ba){if(_0x27d3ba){return[_0x27d3ba,![]];}return db[_0x6de3('0x74')][_0x6de3('0x5d')]({'UserId':_0xa470f[_0x6de3('0x5f')]['id'],'ContactId':_0x451381['id'],'FaxAccountId':_0x5a52c3['id'],'fax':_0xa470f['body']['to'][0x0],'firstMsgDirection':_0x6de3('0xba'),'Messages':[_['merge'](_0xa470f['body'],{'read':![],'body':_0xa470f['body'][_0x6de3('0xaf')][0x0]['filename'],'FaxAccountId':_0x5a52c3['id'],'UserId':_0xa470f[_0x6de3('0x5f')]['id'],'ContactId':_0x451381['id'],'AttachmentId':_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0]['id']})]},{'include':[{'model':db['FaxMessage'],'as':'Messages'}]})['then'](function(_0x598681){return[_0x598681,!![]];});});}else{throw new Error(_0x6de3('0xbb'));}})[_0x6de3('0xbc')](function(_0x15147a,_0x4e8d3b){if(_0x4e8d3b){return _0x15147a;}return db['FaxMessage'][_0x6de3('0x5d')]({'direction':_0x6de3('0xba'),'read':![],'body':_0xa470f[_0x6de3('0x5e')]['attachments'][0x0][_0x6de3('0xbd')],'FaxAccountId':_0x5a52c3['id'],'FaxInteractionId':_0x15147a['id'],'UserId':_0xa470f[_0x6de3('0x5f')]['id'],'ContactId':_0x15147a[_0x6de3('0xbe')],'AttachmentId':_0xa470f[_0x6de3('0x5e')]['attachments'][0x0]['id']})[_0x6de3('0x35')](function(_0x37c180){_0x15147a[_0x6de3('0xbf')][_0x6de3('0xc0')]=[];_0x15147a[_0x6de3('0xbf')][_0x6de3('0xc0')][_0x6de3('0x92')](_0x37c180[_0x6de3('0xbf')]);return _0x15147a;});})['then'](function(_0x16418e){respondWithRpcPromise(_0x6de3('0xc1'),_0x6de3('0xc1'),{'FaxAccountId':_['isNil'](_0xa470f[_0x6de3('0x59')]['id'])?undefined:_0xa470f['params']['id'],'path':_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0][_0x6de3('0xb5')])?undefined:_0xa470f[_0x6de3('0x5e')]['attachments'][0x0][_0x6de3('0xb5')],'fax':_[_0x6de3('0xb4')](_0xa470f[_0x6de3('0x5e')]['to'][0x0])?undefined:_0xa470f[_0x6de3('0x5e')]['to'][0x0],'AttachmentId':_0xa470f[_0x6de3('0x5e')][_0x6de3('0xaf')][0x0]['id']},client9002)['then'](function(_0x302c61){logger['info'](_0x6de3('0xc2'),_0x302c61);})[_0x6de3('0x26')](function(_0x389afb){logger['info']('SendFaxRpc,\x20%s',_0x389afb);});return _0x16418e;})['then'](respondWithResult(_0x4a98c0,null))[_0x6de3('0x26')](handleError(_0x4a98c0,null));};exports[_0x6de3('0xc3')]=function(_0x433e52,_0xe70949,_0x49c920){return db[_0x6de3('0x40')]['find']({'where':{'id':_0x433e52[_0x6de3('0x59')]['id']}})['then'](handleEntityNotFound(_0xe70949,null))[_0x6de3('0x35')](function(_0x13d300){if(_0x13d300){return _0x13d300[_0x6de3('0xc3')](_0x433e52[_0x6de3('0x5e')][_0x6de3('0x6b')],_[_0x6de3('0x72')](_0x433e52['body'],['ids','id'])||{})[_0x6de3('0xbc')](function(_0x1db16e){for(var _0x496380=0x0;_0x496380<_0x433e52['body'][_0x6de3('0x6b')][_0x6de3('0x5a')];_0x496380+=0x1){socket[_0x6de3('0xc4')]('userFaxAccount:save',{'UserId':Number(_0x433e52['body'][_0x6de3('0x6b')][_0x496380]),'FaxAccountId':Number(_0x433e52[_0x6de3('0x59')]['id'])});}return _0x1db16e;});}})['then'](respondWithResult(_0xe70949,null))[_0x6de3('0x26')](handleError(_0xe70949,null));};exports['removeAgents']=function(_0x3c95dc,_0x575114,_0x1acbe3){return db[_0x6de3('0x40')][_0x6de3('0x5c')]({'where':{'id':_0x3c95dc[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x575114,null))[_0x6de3('0x35')](function(_0x2f466f){if(_0x2f466f){return _0x2f466f['removeAgents'](_0x3c95dc[_0x6de3('0x45')][_0x6de3('0x6b')])[_0x6de3('0x35')](function(){if(_[_0x6de3('0xc5')](_0x3c95dc[_0x6de3('0x45')][_0x6de3('0x6b')])){for(var _0x264e25=0x0;_0x264e25<_0x3c95dc[_0x6de3('0x45')]['ids']['length'];_0x264e25+=0x1){socket['emit'](_0x6de3('0xc6'),{'UserId':Number(_0x3c95dc['query'][_0x6de3('0x6b')][_0x264e25]),'FaxAccountId':Number(_0x3c95dc[_0x6de3('0x59')]['id'])});}}else{socket[_0x6de3('0xc4')](_0x6de3('0xc6'),{'UserId':Number(_0x3c95dc[_0x6de3('0x45')][_0x6de3('0x6b')]),'FaxAccountId':Number(_0x3c95dc[_0x6de3('0x59')]['id'])});}});}})[_0x6de3('0x35')](respondWithStatusCode(_0x575114,null))[_0x6de3('0x26')](handleError(_0x575114,null));};exports['getAgents']=function(_0x514fe7,_0x2f8677,_0x108df6){var _0x28a96a={};var _0x508fd4={};var _0x24d6b4;var _0x4a717a;return db['FaxAccount'][_0x6de3('0x6f')]({'where':{'id':_0x514fe7[_0x6de3('0x59')]['id']}})[_0x6de3('0x35')](handleEntityNotFound(_0x2f8677,null))[_0x6de3('0x35')](function(_0x4e7395){if(_0x4e7395){_0x24d6b4=_0x4e7395;_0x508fd4['model']=_[_0x6de3('0x46')](db[_0x6de3('0x77')]['rawAttributes']);_0x508fd4[_0x6de3('0x45')]=_[_0x6de3('0x46')](_0x514fe7['query']);_0x508fd4[_0x6de3('0x47')]=_[_0x6de3('0x48')](_0x508fd4[_0x6de3('0x44')],_0x508fd4[_0x6de3('0x45')]);_0x28a96a['attributes']=_[_0x6de3('0x48')](_0x508fd4[_0x6de3('0x44')],qs[_0x6de3('0x4a')](_0x514fe7[_0x6de3('0x45')][_0x6de3('0x4a')]));_0x28a96a[_0x6de3('0x49')]=_0x28a96a[_0x6de3('0x49')][_0x6de3('0x5a')]?_0x28a96a[_0x6de3('0x49')]:_0x508fd4[_0x6de3('0x44')];_0x28a96a[_0x6de3('0x4d')]=qs[_0x6de3('0x4e')](_0x514fe7['query']['sort']);_0x28a96a[_0x6de3('0x50')]=qs[_0x6de3('0x47')](_[_0x6de3('0x75')](_0x514fe7[_0x6de3('0x45')],_0x508fd4[_0x6de3('0x47')]));if(_0x514fe7['query'][_0x6de3('0x4f')]){_0x28a96a['where']=_[_0x6de3('0x51')](_0x28a96a[_0x6de3('0x50')],{'$or':_[_0x6de3('0x3f')](_0x28a96a['attributes'],function(_0x579054){var _0x504eb2={};_0x504eb2[_0x579054]={'$like':'%'+_0x514fe7[_0x6de3('0x45')]['filter']+'%'};return _0x504eb2;})});}_0x28a96a=_[_0x6de3('0x51')]({},_0x28a96a,_0x514fe7[_0x6de3('0x54')]);return _0x24d6b4[_0x6de3('0xc7')](_0x28a96a);}})[_0x6de3('0x35')](function(_0x4d6c86){if(_0x4d6c86){_0x4a717a=_0x4d6c86[_0x6de3('0x5a')];if(!_0x514fe7[_0x6de3('0x45')][_0x6de3('0x4b')](_0x6de3('0x4c'))){_0x28a96a[_0x6de3('0x2b')]=qs[_0x6de3('0x2b')](_0x514fe7[_0x6de3('0x45')]['limit']);_0x28a96a[_0x6de3('0x29')]=qs[_0x6de3('0x29')](_0x514fe7[_0x6de3('0x45')][_0x6de3('0x29')]);}return _0x24d6b4[_0x6de3('0xc7')](_0x28a96a);}})['then'](function(_0x2ec867){if(_0x2ec867){return _0x2ec867?{'count':_0x4a717a,'rows':_0x2ec867}:null;}})[_0x6de3('0x35')](respondWithResult(_0x2f8677,null))[_0x6de3('0x26')](handleError(_0x2f8677,null));};
\ No newline at end of file
+var _0xb41d=['filter','merge','where','VIRTUAL','findAll','rows','show','params','Pause','length','includeAll','include','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','update','addDisposition','FaxAccountId','getDispositions','findOne','Disposition','removeDispositions','ids','CannedAnswer','getAnswers','removeAnswers','addInteraction','FaxInteraction','omit','CmContact','Owner','fullname','internal','Tag','Tags','color','tag','addApplications','sequelize','transaction','Transaction','FaxApplication','bulkCreate','findAndCountAll','priority','finally','getApplications','from-voip-provider','exten','localstationid','app','system','description','Fax\x20Extension','appdata','push','Answer','ecm','gateway','faxdetect','headerinfo','maxrate','minrate','t38timeout','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','ReceiveFax','addAccountApplications','VoiceExtension','updateAccountApplications','createdAt','updatedAt','ListId','findById','getMessages','FaxMessage','$gte','YYYY-MM-DD\x20HH:mm:ss','CmList','List','attachments','join','root','server/files/attachments','basename','CheckAfterSend','isNil','format','fax','Contacts','List\x20not\x20found','Send\x20Fax\x20failed','out','filename','Messages','Contact\x20not\x20found','spread','dataValues','SendFax','SendFaxRpc,\x20%s','emit','removeAgents','userFaxAccount:remove','User','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','jayson/promise','http','client','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','end','status','json','offset','undefined','limit','count','Content-Range','reject','save','destroy','get','FaxAccounts','UserProfileResource','stack','name','send','index','mandatoryDispositionPause','FaxAccount','rawAttributes','fieldName','type','key','model','map','keys','query','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','filters','pick'];(function(_0x58c456,_0x5804a6){var _0x5555c0=function(_0x20f9c1){while(--_0x20f9c1){_0x58c456['push'](_0x58c456['shift']());}};_0x5555c0(++_0x5804a6);}(_0xb41d,0x6f));var _0xdb41=function(_0x256b72,_0x340985){_0x256b72=_0x256b72-0x0;var _0x2183e3=_0xb41d[_0x256b72];return _0x2183e3;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xdb41('0x0'));var zipdir=require(_0xdb41('0x1'));var jsonpatch=require(_0xdb41('0x2'));var rp=require(_0xdb41('0x3'));var moment=require(_0xdb41('0x4'));var BPromise=require(_0xdb41('0x5'));var Mustache=require(_0xdb41('0x6'));var util=require('util');var path=require(_0xdb41('0x7'));var sox=require(_0xdb41('0x8'));var csv=require(_0xdb41('0x9'));var ejs=require(_0xdb41('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xdb41('0xb'));var squel=require(_0xdb41('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xdb41('0xd'));var toCsv=require(_0xdb41('0x9'));var querystring=require(_0xdb41('0xe'));var Papa=require(_0xdb41('0xf'));var Redis=require('ioredis');var authService=require(_0xdb41('0x10'));var qs=require(_0xdb41('0x11'));var as=require(_0xdb41('0x12'));var hardwareService=require(_0xdb41('0x13'));var logger=require(_0xdb41('0x14'))(_0xdb41('0x15'));var utils=require('../../config/utils');var config=require(_0xdb41('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xdb41('0x17'))['db'];config[_0xdb41('0x18')]=_[_0xdb41('0x19')](config[_0xdb41('0x18')],{'host':_0xdb41('0x1a'),'port':0x18eb});var socket=require(_0xdb41('0x1b'))(new Redis(config[_0xdb41('0x18')]));require(_0xdb41('0x1c'))['register'](socket);var jayson=require(_0xdb41('0x1d'));var client=jayson['client'][_0xdb41('0x1e')]({'port':0x232c});var client9002=jayson[_0xdb41('0x1f')][_0xdb41('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x570240,_0x241238,_0xc31d8f,_0x5bdaad){return new BPromise(function(_0x413325,_0x4dba8a){var _0x76ed79=_0x5bdaad||client;return _0x76ed79[_0xdb41('0x20')](_0x570240,_0xc31d8f)[_0xdb41('0x21')](function(_0x306fae){logger[_0xdb41('0x22')](_0xdb41('0x23'),_0x241238,_0xdb41('0x24'));logger[_0xdb41('0x25')](_0xdb41('0x26'),_0x241238,_0xdb41('0x24'),JSON[_0xdb41('0x27')](_0x306fae));if(_0x306fae[_0xdb41('0x28')]){if(_0x306fae[_0xdb41('0x28')][_0xdb41('0x29')]===0x1f4){logger['error']('FaxAccount,\x20%s,\x20%s',_0x241238,_0x306fae[_0xdb41('0x28')][_0xdb41('0x2a')]);return _0x4dba8a(_0x306fae[_0xdb41('0x28')][_0xdb41('0x2a')]);}logger[_0xdb41('0x28')](_0xdb41('0x23'),_0x241238,_0x306fae[_0xdb41('0x28')]['message']);return _0x413325(_0x306fae[_0xdb41('0x28')][_0xdb41('0x2a')]);}else{logger['info'](_0xdb41('0x23'),_0x241238,_0xdb41('0x24'));_0x413325(_0x306fae[_0xdb41('0x2b')][_0xdb41('0x2a')]);}})[_0xdb41('0x2c')](function(_0x660d04){logger[_0xdb41('0x28')](_0xdb41('0x23'),_0x241238,_0x660d04);_0x4dba8a(_0x660d04);});});}function respondWithStatusCode(_0x36108c,_0x4e6410){_0x4e6410=_0x4e6410||0xcc;return function(_0x21ea64){if(_0x21ea64){return _0x36108c[_0xdb41('0x2d')](_0x4e6410);}return _0x36108c['status'](_0x4e6410)[_0xdb41('0x2e')]();};}function respondWithResult(_0x41b8e3,_0x29e425){_0x29e425=_0x29e425||0xc8;return function(_0x5d9e98){if(_0x5d9e98){return _0x41b8e3[_0xdb41('0x2f')](_0x29e425)[_0xdb41('0x30')](_0x5d9e98);}};}function respondWithFilteredResult(_0x5c087b,_0x4e5e6f){return function(_0x40ae01){if(_0x40ae01){var _0x1f2ae9=typeof _0x4e5e6f[_0xdb41('0x31')]===_0xdb41('0x32')&&typeof _0x4e5e6f[_0xdb41('0x33')]===_0xdb41('0x32');var _0x417e23=_0x40ae01[_0xdb41('0x34')];var _0x624f0c=_0x1f2ae9?0x0:_0x4e5e6f['offset'];var _0x35d8e0=_0x1f2ae9?_0x40ae01['count']:_0x4e5e6f['offset']+_0x4e5e6f[_0xdb41('0x33')];var _0x443be8;if(_0x35d8e0>=_0x417e23){_0x35d8e0=_0x417e23;_0x443be8=0xc8;}else{_0x443be8=0xce;}_0x5c087b[_0xdb41('0x2f')](_0x443be8);return _0x5c087b['set'](_0xdb41('0x35'),_0x624f0c+'-'+_0x35d8e0+'/'+_0x417e23)[_0xdb41('0x30')](_0x40ae01);}return null;};}function patchUpdates(_0x1986a9){return function(_0x33d3c3){try{jsonpatch['apply'](_0x33d3c3,_0x1986a9,!![]);}catch(_0x3bf877){return BPromise[_0xdb41('0x36')](_0x3bf877);}return _0x33d3c3[_0xdb41('0x37')]();};}function saveUpdates(_0x173f06,_0x463a7e){return function(_0x20541b){if(_0x20541b){return _0x20541b['update'](_0x173f06)[_0xdb41('0x21')](function(_0x40f1f0){return _0x40f1f0;});}return null;};}function removeEntity(_0x55203e,_0x392f8d){return function(_0x115a08){if(_0x115a08){return _0x115a08[_0xdb41('0x38')]()[_0xdb41('0x21')](function(){var _0x3d1586=_0x115a08[_0xdb41('0x39')]({'plain':!![]});var _0xad4782=_0xdb41('0x3a');return db[_0xdb41('0x3b')][_0xdb41('0x38')]({'where':{'type':_0xad4782,'resourceId':_0x3d1586['id']}})['then'](function(){return _0x115a08;});})['then'](function(){_0x55203e['status'](0xcc)[_0xdb41('0x2e')]();});}};}function handleEntityNotFound(_0x54f7f3,_0x5e71cf){return function(_0x51536a){if(!_0x51536a){_0x54f7f3[_0xdb41('0x2d')](0x194);}return _0x51536a;};}function handleError(_0x5d4c35,_0x4dbcba){_0x4dbcba=_0x4dbcba||0x1f4;return function(_0x20b9a1){logger[_0xdb41('0x28')](_0x20b9a1[_0xdb41('0x3c')]);if(_0x20b9a1[_0xdb41('0x3d')]){delete _0x20b9a1[_0xdb41('0x3d')];}_0x5d4c35[_0xdb41('0x2f')](_0x4dbcba)[_0xdb41('0x3e')](_0x20b9a1);};}exports[_0xdb41('0x3f')]=function(_0x4240d9,_0x728cf3){var _0x3191fc={'include':[{'model':db['Pause'],'as':_0xdb41('0x40')}]},_0x4ebd08={},_0x71811b={'count':0x0,'rows':[]};var _0x265435=_['map'](db[_0xdb41('0x41')][_0xdb41('0x42')],function(_0xc29d34){return{'name':_0xc29d34[_0xdb41('0x43')],'type':_0xc29d34[_0xdb41('0x44')][_0xdb41('0x45')]};});_0x4ebd08[_0xdb41('0x46')]=_[_0xdb41('0x47')](_0x265435,'name');_0x4ebd08['query']=_[_0xdb41('0x48')](_0x4240d9[_0xdb41('0x49')]);_0x4ebd08['filters']=_[_0xdb41('0x4a')](_0x4ebd08[_0xdb41('0x46')],_0x4ebd08[_0xdb41('0x49')]);_0x3191fc['attributes']=_[_0xdb41('0x4a')](_0x4ebd08[_0xdb41('0x46')],qs[_0xdb41('0x4b')](_0x4240d9[_0xdb41('0x49')][_0xdb41('0x4b')]));_0x3191fc['attributes']=_0x3191fc[_0xdb41('0x4c')]['length']?_0x3191fc[_0xdb41('0x4c')]:_0x4ebd08[_0xdb41('0x46')];if(!_0x4240d9[_0xdb41('0x49')][_0xdb41('0x4d')](_0xdb41('0x4e'))){_0x3191fc[_0xdb41('0x33')]=qs[_0xdb41('0x33')](_0x4240d9['query'][_0xdb41('0x33')]);_0x3191fc[_0xdb41('0x31')]=qs[_0xdb41('0x31')](_0x4240d9[_0xdb41('0x49')][_0xdb41('0x31')]);}_0x3191fc[_0xdb41('0x4f')]=qs[_0xdb41('0x50')](_0x4240d9[_0xdb41('0x49')][_0xdb41('0x50')]);_0x3191fc['where']=qs[_0xdb41('0x51')](_[_0xdb41('0x52')](_0x4240d9[_0xdb41('0x49')],_0x4ebd08['filters']),_0x265435);if(_0x4240d9[_0xdb41('0x49')][_0xdb41('0x53')]){_0x3191fc['where']=_[_0xdb41('0x54')](_0x3191fc[_0xdb41('0x55')],{'$or':_[_0xdb41('0x47')](_0x265435,function(_0x33ae0b){if(_0x33ae0b[_0xdb41('0x44')]!==_0xdb41('0x56')){var _0x1658d3={};_0x1658d3[_0x33ae0b[_0xdb41('0x3d')]]={'$like':'%'+_0x4240d9[_0xdb41('0x49')]['filter']+'%'};return _0x1658d3;}})});}_0x3191fc=_[_0xdb41('0x54')]({},_0x3191fc,_0x4240d9['options']);var _0x4f20e7={'where':_0x3191fc[_0xdb41('0x55')]};return db['FaxAccount'][_0xdb41('0x34')](_0x4f20e7)['then'](function(_0x524a01){_0x71811b[_0xdb41('0x34')]=_0x524a01;if(_0x4240d9[_0xdb41('0x49')]['includeAll']){_0x3191fc['include']=[{'all':!![]}];}return db[_0xdb41('0x41')][_0xdb41('0x57')](_0x3191fc);})[_0xdb41('0x21')](function(_0x4e66e7){_0x71811b[_0xdb41('0x58')]=_0x4e66e7;return _0x71811b;})[_0xdb41('0x21')](respondWithFilteredResult(_0x728cf3,_0x3191fc))[_0xdb41('0x2c')](handleError(_0x728cf3,null));};exports[_0xdb41('0x59')]=function(_0x57aaf0,_0x5cfdad){var _0x57ca15={'raw':![],'where':{'id':_0x57aaf0[_0xdb41('0x5a')]['id']},'include':[{'model':db[_0xdb41('0x5b')],'as':'mandatoryDispositionPause'}]},_0x99f69c={};_0x99f69c[_0xdb41('0x46')]=_[_0xdb41('0x48')](db['FaxAccount'][_0xdb41('0x42')]);_0x99f69c['query']=_[_0xdb41('0x48')](_0x57aaf0[_0xdb41('0x49')]);_0x99f69c['filters']=_[_0xdb41('0x4a')](_0x99f69c[_0xdb41('0x46')],_0x99f69c[_0xdb41('0x49')]);_0x57ca15[_0xdb41('0x4c')]=_[_0xdb41('0x4a')](_0x99f69c[_0xdb41('0x46')],qs['fields'](_0x57aaf0[_0xdb41('0x49')][_0xdb41('0x4b')]));_0x57ca15[_0xdb41('0x4c')]=_0x57ca15[_0xdb41('0x4c')][_0xdb41('0x5c')]?_0x57ca15[_0xdb41('0x4c')]:_0x99f69c['model'];if(_0x57aaf0[_0xdb41('0x49')][_0xdb41('0x5d')]){_0x57ca15[_0xdb41('0x5e')]=[{'all':!![]}];}_0x57ca15=_[_0xdb41('0x54')]({},_0x57ca15,_0x57aaf0[_0xdb41('0x5f')]);return db['FaxAccount']['find'](_0x57ca15)[_0xdb41('0x21')](handleEntityNotFound(_0x5cfdad,null))[_0xdb41('0x21')](respondWithResult(_0x5cfdad,null))['catch'](handleError(_0x5cfdad,null));};exports[_0xdb41('0x60')]=function(_0x282162,_0x428457){return db[_0xdb41('0x41')][_0xdb41('0x60')](_0x282162[_0xdb41('0x61')],{})[_0xdb41('0x21')](function(_0x5006b5){var _0x1f7608=_0x282162[_0xdb41('0x62')][_0xdb41('0x39')]({'plain':!![]});if(!_0x1f7608)throw new Error(_0xdb41('0x63'));if(_0x1f7608[_0xdb41('0x64')]==='user'){var _0x38dc33=_0x5006b5[_0xdb41('0x39')]({'plain':!![]});var _0x494b3b=_0xdb41('0x3a');return db[_0xdb41('0x65')][_0xdb41('0x66')]({'where':{'name':_0x494b3b,'userProfileId':_0x1f7608[_0xdb41('0x67')]},'raw':!![]})[_0xdb41('0x21')](function(_0x282c8c){if(_0x282c8c&&_0x282c8c[_0xdb41('0x68')]===0x0){return db[_0xdb41('0x3b')][_0xdb41('0x60')]({'name':_0x38dc33[_0xdb41('0x3d')],'resourceId':_0x38dc33['id'],'type':_0x282c8c['name'],'sectionId':_0x282c8c['id']},{})['then'](function(){return _0x5006b5;});}else{return _0x5006b5;}})[_0xdb41('0x2c')](function(_0x1de5f8){logger[_0xdb41('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1de5f8);throw _0x1de5f8;});}return _0x5006b5;})[_0xdb41('0x21')](respondWithResult(_0x428457,0xc9))['catch'](handleError(_0x428457,null));};exports[_0xdb41('0x69')]=function(_0x161d3c,_0x460fc1){if(_0x161d3c[_0xdb41('0x61')]['id']){delete _0x161d3c['body']['id'];}return db[_0xdb41('0x41')][_0xdb41('0x66')]({'where':{'id':_0x161d3c[_0xdb41('0x5a')]['id']},'include':[{'model':db[_0xdb41('0x5b')],'as':_0xdb41('0x40')}]})[_0xdb41('0x21')](handleEntityNotFound(_0x460fc1,null))[_0xdb41('0x21')](saveUpdates(_0x161d3c[_0xdb41('0x61')],null))[_0xdb41('0x21')](respondWithResult(_0x460fc1,null))[_0xdb41('0x2c')](handleError(_0x460fc1,null));};exports[_0xdb41('0x38')]=function(_0x2b9bc3,_0x5a972d){return db[_0xdb41('0x41')][_0xdb41('0x66')]({'where':{'id':_0x2b9bc3[_0xdb41('0x5a')]['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x5a972d,null))['then'](removeEntity(_0x5a972d,null))[_0xdb41('0x2c')](handleError(_0x5a972d,null));};exports['describe']=function(_0x269a61,_0x6871ab){return db[_0xdb41('0x41')]['describe']()[_0xdb41('0x21')](respondWithResult(_0x6871ab,null))[_0xdb41('0x2c')](handleError(_0x6871ab,null));};exports[_0xdb41('0x6a')]=function(_0x863c8c,_0x254a51,_0x335086){if(_0x863c8c[_0xdb41('0x61')]['id']){delete _0x863c8c[_0xdb41('0x61')]['id'];}return db[_0xdb41('0x41')][_0xdb41('0x66')]({'where':{'id':_0x863c8c[_0xdb41('0x5a')]['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x254a51,null))['then'](function(_0x576cd2){if(_0x576cd2){_0x863c8c['body'][_0xdb41('0x6b')]=_0x576cd2['id'];return db['Disposition'][_0xdb41('0x60')](_0x863c8c[_0xdb41('0x61')]);}})[_0xdb41('0x21')](respondWithResult(_0x254a51,null))[_0xdb41('0x2c')](handleError(_0x254a51,null));};exports[_0xdb41('0x6c')]=function(_0x58b7d8,_0x4657cd,_0x154ea6){var _0x4efcd9={'raw':![],'where':{}};var _0x49258d={};var _0x14e33e={'count':0x0,'rows':[]};return db[_0xdb41('0x41')][_0xdb41('0x6d')]({'where':{'id':_0x58b7d8[_0xdb41('0x5a')]['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x4657cd,null))[_0xdb41('0x21')](function(_0x5191dd){if(_0x5191dd){_0x49258d[_0xdb41('0x46')]=_['keys'](db[_0xdb41('0x6e')][_0xdb41('0x42')]);_0x49258d[_0xdb41('0x49')]=_[_0xdb41('0x48')](_0x58b7d8[_0xdb41('0x49')]);_0x49258d[_0xdb41('0x51')]=_[_0xdb41('0x4a')](_0x49258d[_0xdb41('0x46')],_0x49258d[_0xdb41('0x49')]);_0x4efcd9['attributes']=_[_0xdb41('0x4a')](_0x49258d[_0xdb41('0x46')],qs[_0xdb41('0x4b')](_0x58b7d8['query'][_0xdb41('0x4b')]));_0x4efcd9[_0xdb41('0x4c')]=_0x4efcd9[_0xdb41('0x4c')][_0xdb41('0x5c')]?_0x4efcd9[_0xdb41('0x4c')]:_0x49258d[_0xdb41('0x46')];if(!_0x58b7d8[_0xdb41('0x49')][_0xdb41('0x4d')](_0xdb41('0x4e'))){_0x4efcd9[_0xdb41('0x33')]=qs['limit'](_0x58b7d8[_0xdb41('0x49')][_0xdb41('0x33')]);_0x4efcd9[_0xdb41('0x31')]=qs[_0xdb41('0x31')](_0x58b7d8[_0xdb41('0x49')]['offset']);}_0x4efcd9[_0xdb41('0x4f')]=qs[_0xdb41('0x50')](_0x58b7d8[_0xdb41('0x49')][_0xdb41('0x50')]);_0x4efcd9['where']=qs[_0xdb41('0x51')](_[_0xdb41('0x52')](_0x58b7d8['query'],_0x49258d[_0xdb41('0x51')]));_0x4efcd9[_0xdb41('0x55')][_0xdb41('0x6b')]=_0x5191dd['id'];if(_0x58b7d8['query'][_0xdb41('0x53')]){_0x4efcd9['where']=_[_0xdb41('0x54')](_0x4efcd9[_0xdb41('0x55')],{'$or':_[_0xdb41('0x47')](_0x4efcd9[_0xdb41('0x4c')],function(_0x4ca9cb){var _0x468c9b={};_0x468c9b[_0x4ca9cb]={'$like':'%'+_0x58b7d8[_0xdb41('0x49')][_0xdb41('0x53')]+'%'};return _0x468c9b;})});}_0x4efcd9=_[_0xdb41('0x54')]({},_0x4efcd9,_0x58b7d8[_0xdb41('0x5f')]);return db[_0xdb41('0x6e')][_0xdb41('0x34')]({'where':_0x4efcd9[_0xdb41('0x55')]})[_0xdb41('0x21')](function(_0x2f7517){_0x14e33e[_0xdb41('0x34')]=_0x2f7517;if(_0x58b7d8[_0xdb41('0x49')][_0xdb41('0x5d')]){_0x4efcd9[_0xdb41('0x5e')]=[{'all':!![]}];}return db['Disposition']['findAll'](_0x4efcd9);})[_0xdb41('0x21')](function(_0x1e0d29){_0x14e33e['rows']=_0x1e0d29;return _0x14e33e;});}})[_0xdb41('0x21')](respondWithFilteredResult(_0x4657cd,_0x4efcd9))[_0xdb41('0x2c')](handleError(_0x4657cd,null));};exports[_0xdb41('0x6f')]=function(_0x1dea70,_0x26837d,_0x587a40){return db['FaxAccount'][_0xdb41('0x66')]({'where':{'id':_0x1dea70[_0xdb41('0x5a')]['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x26837d,null))[_0xdb41('0x21')](function(_0x39917a){if(_0x39917a){return _0x39917a['removeDispositions'](_0x1dea70['query'][_0xdb41('0x70')]);}})[_0xdb41('0x21')](respondWithStatusCode(_0x26837d,null))['catch'](handleError(_0x26837d,null));};exports['addAnswer']=function(_0xeaffa4,_0x332aa2,_0x28dcfc){if(_0xeaffa4[_0xdb41('0x61')]['id']){delete _0xeaffa4[_0xdb41('0x61')]['id'];}return db[_0xdb41('0x41')]['find']({'where':{'id':_0xeaffa4[_0xdb41('0x5a')]['id']}})['then'](handleEntityNotFound(_0x332aa2,null))[_0xdb41('0x21')](function(_0x3b154c){if(_0x3b154c){_0xeaffa4['body'][_0xdb41('0x6b')]=_0x3b154c['id'];return db[_0xdb41('0x71')][_0xdb41('0x60')](_0xeaffa4[_0xdb41('0x61')]);}})[_0xdb41('0x21')](respondWithResult(_0x332aa2,null))[_0xdb41('0x2c')](handleError(_0x332aa2,null));};exports[_0xdb41('0x72')]=function(_0x5f3e38,_0xef45e3,_0x21b8ff){var _0x177c02={'raw':![],'where':{}};var _0x3e7b58={};var _0x3dcdcd={'count':0x0,'rows':[]};return db[_0xdb41('0x41')][_0xdb41('0x6d')]({'where':{'id':_0x5f3e38[_0xdb41('0x5a')]['id']}})['then'](handleEntityNotFound(_0xef45e3,null))['then'](function(_0x587298){if(_0x587298){_0x3e7b58[_0xdb41('0x46')]=_['keys'](db[_0xdb41('0x71')][_0xdb41('0x42')]);_0x3e7b58[_0xdb41('0x49')]=_['keys'](_0x5f3e38[_0xdb41('0x49')]);_0x3e7b58[_0xdb41('0x51')]=_[_0xdb41('0x4a')](_0x3e7b58[_0xdb41('0x46')],_0x3e7b58[_0xdb41('0x49')]);_0x177c02[_0xdb41('0x4c')]=_[_0xdb41('0x4a')](_0x3e7b58[_0xdb41('0x46')],qs[_0xdb41('0x4b')](_0x5f3e38['query']['fields']));_0x177c02[_0xdb41('0x4c')]=_0x177c02[_0xdb41('0x4c')][_0xdb41('0x5c')]?_0x177c02[_0xdb41('0x4c')]:_0x3e7b58[_0xdb41('0x46')];if(!_0x5f3e38['query'][_0xdb41('0x4d')]('nolimit')){_0x177c02[_0xdb41('0x33')]=qs[_0xdb41('0x33')](_0x5f3e38[_0xdb41('0x49')][_0xdb41('0x33')]);_0x177c02[_0xdb41('0x31')]=qs[_0xdb41('0x31')](_0x5f3e38['query'][_0xdb41('0x31')]);}_0x177c02['order']=qs['sort'](_0x5f3e38['query'][_0xdb41('0x50')]);_0x177c02[_0xdb41('0x55')]=qs[_0xdb41('0x51')](_[_0xdb41('0x52')](_0x5f3e38['query'],_0x3e7b58[_0xdb41('0x51')]));_0x177c02[_0xdb41('0x55')][_0xdb41('0x6b')]=_0x587298['id'];if(_0x5f3e38['query'][_0xdb41('0x53')]){_0x177c02['where']=_[_0xdb41('0x54')](_0x177c02[_0xdb41('0x55')],{'$or':_[_0xdb41('0x47')](_0x177c02[_0xdb41('0x4c')],function(_0x3e8950){var _0x1cba97={};_0x1cba97[_0x3e8950]={'$like':'%'+_0x5f3e38[_0xdb41('0x49')][_0xdb41('0x53')]+'%'};return _0x1cba97;})});}_0x177c02=_[_0xdb41('0x54')]({},_0x177c02,_0x5f3e38['options']);return db['CannedAnswer'][_0xdb41('0x34')]({'where':_0x177c02['where']})[_0xdb41('0x21')](function(_0x334d39){_0x3dcdcd[_0xdb41('0x34')]=_0x334d39;if(_0x5f3e38[_0xdb41('0x49')][_0xdb41('0x5d')]){_0x177c02[_0xdb41('0x5e')]=[{'all':!![]}];}return db[_0xdb41('0x71')][_0xdb41('0x57')](_0x177c02);})[_0xdb41('0x21')](function(_0x1e3246){_0x3dcdcd[_0xdb41('0x58')]=_0x1e3246;return _0x3dcdcd;});}})[_0xdb41('0x21')](respondWithFilteredResult(_0xef45e3,_0x177c02))[_0xdb41('0x2c')](handleError(_0xef45e3,null));};exports[_0xdb41('0x73')]=function(_0x18c8e9,_0x3bcea7,_0x33d78f){return db[_0xdb41('0x41')][_0xdb41('0x66')]({'where':{'id':_0x18c8e9['params']['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x3bcea7,null))[_0xdb41('0x21')](function(_0x4954d3){if(_0x4954d3){return _0x4954d3[_0xdb41('0x73')](_0x18c8e9[_0xdb41('0x49')][_0xdb41('0x70')]);}})[_0xdb41('0x21')](respondWithStatusCode(_0x3bcea7,null))[_0xdb41('0x2c')](handleError(_0x3bcea7,null));};exports[_0xdb41('0x74')]=function(_0x1f6b40,_0x18f109,_0x4cfa05){return db[_0xdb41('0x75')][_0xdb41('0x66')]({'where':{'id':_0x1f6b40[_0xdb41('0x5a')]['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x18f109,null))['then'](function(_0xc35202){if(_0xc35202){return _0xc35202[_0xdb41('0x74')](_0x1f6b40[_0xdb41('0x61')][_0xdb41('0x70')],_[_0xdb41('0x76')](_0x1f6b40[_0xdb41('0x61')],[_0xdb41('0x70'),'id'])||{});}})[_0xdb41('0x21')](respondWithResult(_0x18f109,null))[_0xdb41('0x2c')](handleError(_0x18f109,null));};exports['getInteractions']=function(_0x5e3eec,_0x5f0dc2,_0x3f7060){var _0x2ebcff={'raw':![],'where':{}};var _0x4b3dda={};var _0x42c700={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x5e3eec['params']['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x5f0dc2,null))[_0xdb41('0x21')](function(_0x11c6f8){if(_0x11c6f8){_0x4b3dda[_0xdb41('0x46')]=_['keys'](db[_0xdb41('0x75')][_0xdb41('0x42')]);_0x4b3dda['query']=_[_0xdb41('0x48')](_0x5e3eec[_0xdb41('0x49')]);_0x4b3dda[_0xdb41('0x51')]=_[_0xdb41('0x4a')](_0x4b3dda[_0xdb41('0x46')],_0x4b3dda[_0xdb41('0x49')]);_0x2ebcff[_0xdb41('0x4c')]=_[_0xdb41('0x4a')](_0x4b3dda[_0xdb41('0x46')],qs['fields'](_0x5e3eec[_0xdb41('0x49')][_0xdb41('0x4b')]));_0x2ebcff[_0xdb41('0x4c')]=_0x2ebcff[_0xdb41('0x4c')]['length']?_0x2ebcff[_0xdb41('0x4c')]:_0x4b3dda[_0xdb41('0x46')];if(!_0x5e3eec[_0xdb41('0x49')][_0xdb41('0x4d')](_0xdb41('0x4e'))){_0x2ebcff[_0xdb41('0x33')]=qs[_0xdb41('0x33')](_0x5e3eec[_0xdb41('0x49')]['limit']);_0x2ebcff[_0xdb41('0x31')]=qs[_0xdb41('0x31')](_0x5e3eec[_0xdb41('0x49')]['offset']);}_0x2ebcff['order']=qs[_0xdb41('0x50')](_0x5e3eec['query']['sort']);_0x2ebcff[_0xdb41('0x55')]=qs['filters'](_[_0xdb41('0x52')](_0x5e3eec[_0xdb41('0x49')],_0x4b3dda[_0xdb41('0x51')]));_0x2ebcff[_0xdb41('0x55')][_0xdb41('0x6b')]=_0x11c6f8['id'];if(_0x5e3eec[_0xdb41('0x49')][_0xdb41('0x53')]){_0x2ebcff[_0xdb41('0x55')]=_[_0xdb41('0x54')](_0x2ebcff[_0xdb41('0x55')],{'$or':_['map'](_0x2ebcff['attributes'],function(_0x17edf9){var _0x12fd65={};_0x12fd65[_0x17edf9]={'$like':'%'+_0x5e3eec[_0xdb41('0x49')][_0xdb41('0x53')]+'%'};return _0x12fd65;})});}_0x2ebcff=_[_0xdb41('0x54')]({},_0x2ebcff,_0x5e3eec[_0xdb41('0x5f')]);return db['FaxInteraction']['count']({'where':_0x2ebcff[_0xdb41('0x55')]})[_0xdb41('0x21')](function(_0x4a7a91){_0x42c700[_0xdb41('0x34')]=_0x4a7a91;if(_0x5e3eec[_0xdb41('0x49')][_0xdb41('0x5d')]){_0x2ebcff['include']=[{'model':db[_0xdb41('0x77')],'as':'Contact','required':![]},{'model':db['User'],'as':_0xdb41('0x78'),'attributes':[_0xdb41('0x3d'),_0xdb41('0x79'),_0xdb41('0x7a')],'required':![]},{'model':db[_0xdb41('0x7b')],'as':_0xdb41('0x7c'),'attributes':['id','name',_0xdb41('0x7d')],'where':_0x5e3eec['query'][_0xdb41('0x7e')]?{'id':_0x5e3eec[_0xdb41('0x49')]['tag']}:undefined,'required':_0x5e3eec[_0xdb41('0x49')][_0xdb41('0x7e')]?!![]:![]}];}return db[_0xdb41('0x75')][_0xdb41('0x57')](_0x2ebcff);})[_0xdb41('0x21')](function(_0x1d3deb){_0x42c700[_0xdb41('0x58')]=_0x1d3deb;return _0x42c700;});}})[_0xdb41('0x21')](respondWithFilteredResult(_0x5f0dc2,_0x2ebcff))[_0xdb41('0x2c')](handleError(_0x5f0dc2,null));};exports[_0xdb41('0x7f')]=function(_0x132bd5,_0x316865){var _0x565485=_0x132bd5[_0xdb41('0x5a')]['id'];var _0x487c8f=_0x132bd5[_0xdb41('0x61')];var _0x371a34=0xc8;var _0x46611a=null;return db[_0xdb41('0x80')][_0xdb41('0x81')]({'isolationLevel':db['sequelize'][_0xdb41('0x82')]['ISOLATION_LEVELS']['READ_COMMITTED']},function(_0x41bcfb){return db[_0xdb41('0x41')][_0xdb41('0x6d')]({'where':{'id':_0x565485},'transaction':_0x41bcfb})[_0xdb41('0x21')](function(_0x3bb35d){if(_0x3bb35d){return db[_0xdb41('0x83')][_0xdb41('0x38')]({'where':{'FaxAccountId':_0x565485},'transaction':_0x41bcfb})['then'](function(){var _0x3390d9=_[_0xdb41('0x47')](_0x487c8f,function(_0x54efd5){_0x54efd5['FaxAccountId']=_0x565485;return _0x54efd5;});return db['FaxApplication'][_0xdb41('0x84')](_0x3390d9,{'transaction':_0x41bcfb});});}else{_0x371a34=0x194;_0x46611a=[];}});})[_0xdb41('0x21')](function(){if(_0x371a34!==0x194){return db[_0xdb41('0x83')][_0xdb41('0x85')]({'where':{'FaxAccountId':_0x565485},'order':_0xdb41('0x86')})['then'](function(_0x16bc45){_0x46611a=_0x16bc45;});}})[_0xdb41('0x2c')](function(_0x58ccbe){_0x371a34=0x1f4;logger[_0xdb41('0x28')](_0x58ccbe[_0xdb41('0x3c')]);if(_0x58ccbe['name']){delete _0x58ccbe['name'];}_0x46611a=_0x58ccbe;})[_0xdb41('0x87')](function(){if(_0x46611a===null){_0x316865[_0xdb41('0x2d')](_0x371a34);}else{if(_0x371a34===0x1f4){_0x316865[_0xdb41('0x2f')](_0x371a34)[_0xdb41('0x3e')](_0x46611a);}else{_0x316865[_0xdb41('0x2f')](_0x371a34)['json'](_0x46611a);}}});};exports['getApplications']=function(_0x5e6318,_0x3535cd,_0x598d10){var _0x2df6ea={};var _0x51995e={};var _0x382880;var _0x240dbe;return db[_0xdb41('0x41')][_0xdb41('0x6d')]({'where':{'id':_0x5e6318[_0xdb41('0x5a')]['id']}})['then'](handleEntityNotFound(_0x3535cd,null))['then'](function(_0x1cc364){if(_0x1cc364){_0x382880=_0x1cc364;_0x51995e[_0xdb41('0x46')]=_[_0xdb41('0x48')](db[_0xdb41('0x83')][_0xdb41('0x42')]);_0x51995e[_0xdb41('0x49')]=_['keys'](_0x5e6318[_0xdb41('0x49')]);_0x51995e[_0xdb41('0x51')]=_[_0xdb41('0x4a')](_0x51995e[_0xdb41('0x46')],_0x51995e['query']);_0x2df6ea[_0xdb41('0x4c')]=_[_0xdb41('0x4a')](_0x51995e['model'],qs[_0xdb41('0x4b')](_0x5e6318[_0xdb41('0x49')]['fields']));_0x2df6ea[_0xdb41('0x4c')]=_0x2df6ea['attributes']['length']?_0x2df6ea[_0xdb41('0x4c')]:_0x51995e[_0xdb41('0x46')];_0x2df6ea[_0xdb41('0x4f')]=qs[_0xdb41('0x50')](_0x5e6318['query'][_0xdb41('0x50')]);_0x2df6ea[_0xdb41('0x55')]=qs[_0xdb41('0x51')](_['pick'](_0x5e6318[_0xdb41('0x49')],_0x51995e[_0xdb41('0x51')]));if(_0x5e6318[_0xdb41('0x49')][_0xdb41('0x53')]){_0x2df6ea[_0xdb41('0x55')]=_[_0xdb41('0x54')](_0x2df6ea[_0xdb41('0x55')],{'$or':_[_0xdb41('0x47')](_0x2df6ea['attributes'],function(_0x2ed864){var _0x3d047f={};_0x3d047f[_0x2ed864]={'$like':'%'+_0x5e6318[_0xdb41('0x49')]['filter']+'%'};return _0x3d047f;})});}_0x2df6ea=_['merge']({},_0x2df6ea,_0x5e6318[_0xdb41('0x5f')]);return _0x382880[_0xdb41('0x88')](_0x2df6ea);}})[_0xdb41('0x21')](function(_0x4993a2){if(_0x4993a2){_0x240dbe=_0x4993a2[_0xdb41('0x5c')];if(!_0x5e6318['query'][_0xdb41('0x4d')]('nolimit')){_0x2df6ea[_0xdb41('0x33')]=qs[_0xdb41('0x33')](_0x5e6318[_0xdb41('0x49')][_0xdb41('0x33')]);_0x2df6ea[_0xdb41('0x31')]=qs[_0xdb41('0x31')](_0x5e6318[_0xdb41('0x49')][_0xdb41('0x31')]);}return _0x382880[_0xdb41('0x88')](_0x2df6ea);}})[_0xdb41('0x21')](function(_0x296390){if(_0x296390){return _0x296390?{'count':_0x240dbe,'rows':_0x296390}:null;}})['then'](respondWithResult(_0x3535cd,null))['catch'](handleError(_0x3535cd,null));};function Extension(_0x153108,_0x21a7e6,_0x1967ae,_0x4288c0){this['context']=_0xdb41('0x89');this[_0xdb41('0x8a')]=_0x153108[_0xdb41('0x8b')];this[_0xdb41('0x8c')]=_0x4288c0;this[_0xdb41('0x44')]=_0xdb41('0x8d');this[_0xdb41('0x8e')]=_0xdb41('0x8f');this['FaxAccountId']=_0x153108['id'];this['priority']=_0x21a7e6;this[_0xdb41('0x90')]=_0x1967ae;}function createExtensionsReciveFax(_0x5d90a0){var _0xa2c7bd=0x1;var _0x367576=[];_0x367576[_0xdb41('0x91')](new Extension(_0x5d90a0,_0xa2c7bd,'',_0xdb41('0x92')));_0xa2c7bd+=0x1;_0x367576['push'](new Extension(_0x5d90a0,_0xa2c7bd,'CDR(type)=inbound-fax','Set'));_0xa2c7bd+=0x1;for(var _0x51b8de in _0x5d90a0){if(_0x5d90a0[_0xdb41('0x4d')](_0x51b8de)&&(_0x51b8de===_0xdb41('0x93')||_0x51b8de==='localstationid'||_0x51b8de===_0xdb41('0x94')||_0x51b8de===_0xdb41('0x95')||_0x51b8de===_0xdb41('0x96')||_0x51b8de===_0xdb41('0x97')||_0x51b8de===_0xdb41('0x98')||_0x51b8de==='modem'||_0x51b8de===_0xdb41('0x99'))){_0x367576[_0xdb41('0x91')](new Extension(_0x5d90a0,_0xa2c7bd,'FAXOPT('+_0x51b8de+')='+_0x5d90a0[_0x51b8de],'Set'));_0xa2c7bd+=0x1;}}_0x367576[_0xdb41('0x91')](new Extension(_0x5d90a0,_0xa2c7bd,'6','Wait'));_0xa2c7bd+=0x1;_0x367576[_0xdb41('0x91')](new Extension(_0x5d90a0,_0xa2c7bd,_0xdb41('0x9a'),_0xdb41('0x9b')));_0xa2c7bd=0x0;return _0x367576;}exports[_0xdb41('0x9c')]=function(_0x429092,_0x1167f5,_0x46a793){var _0x23eddd;return db[_0xdb41('0x80')][_0xdb41('0x81')](function(_0x41165a){return db[_0xdb41('0x41')][_0xdb41('0x60')](_0x429092[_0xdb41('0x61')],{'transaction':_0x41165a})['then'](function(_0x3e51cb){_0x23eddd=_0x3e51cb[_0xdb41('0x39')]({'plain':!![]});return db[_0xdb41('0x9d')]['bulkCreate'](createExtensionsReciveFax(_0x23eddd),{'transaction':_0x41165a});});})[_0xdb41('0x21')](function(){return _0x23eddd;})[_0xdb41('0x21')](respondWithResult(_0x1167f5,null))[_0xdb41('0x2c')](handleError(_0x1167f5,null));};exports[_0xdb41('0x9e')]=function(_0x3fbf7f,_0x3f74a0,_0x199bf7){var _0xd93ec0;return db[_0xdb41('0x80')][_0xdb41('0x81')](function(_0x385452){return db[_0xdb41('0x41')]['update'](_0x3fbf7f[_0xdb41('0x61')],{'where':{'id':_0x3fbf7f[_0xdb41('0x61')]['id']},'transaction':_0x385452})[_0xdb41('0x21')](function(_0x4aabb1){return db[_0xdb41('0x9d')][_0xdb41('0x38')]({'where':{'FaxAccountId':_0x3fbf7f[_0xdb41('0x61')]['id']},'transaction':_0x385452})[_0xdb41('0x21')](function(_0x3f5a17){return db[_0xdb41('0x9d')]['bulkCreate'](createExtensionsReciveFax(_[_0xdb41('0x76')](_0x3fbf7f[_0xdb41('0x61')],['tech',_0xdb41('0x45'),_0xdb41('0x9f'),_0xdb41('0xa0'),'TrunkId',_0xdb41('0xa1')])),{'transaction':_0x385452});});});})['then'](function(){return db[_0xdb41('0x41')][_0xdb41('0xa2')](_0x3fbf7f['body']['id']);})[_0xdb41('0x21')](respondWithResult(_0x3f74a0,null))['catch'](handleError(_0x3f74a0,null));};exports[_0xdb41('0xa3')]=function(_0x45fdf8,_0x674676,_0x71fec2){var _0x2d0cdf={'raw':!![],'where':{}};var _0x4be083={};var _0x5abfa8={'count':0x0,'rows':[]};return db[_0xdb41('0x41')]['findOne']({'where':{'id':_0x45fdf8[_0xdb41('0x5a')]['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x674676,null))[_0xdb41('0x21')](function(_0x14b6f3){if(_0x14b6f3){_0x4be083[_0xdb41('0x46')]=_[_0xdb41('0x48')](db[_0xdb41('0xa4')]['rawAttributes']);_0x4be083['query']=_['keys'](_0x45fdf8[_0xdb41('0x49')]);_0x4be083[_0xdb41('0x51')]=_[_0xdb41('0x4a')](_0x4be083[_0xdb41('0x46')],_0x4be083[_0xdb41('0x49')]);_0x2d0cdf['attributes']=_['intersection'](_0x4be083[_0xdb41('0x46')],qs[_0xdb41('0x4b')](_0x45fdf8['query'][_0xdb41('0x4b')]));_0x2d0cdf[_0xdb41('0x4c')]=_0x2d0cdf['attributes'][_0xdb41('0x5c')]?_0x2d0cdf['attributes']:_0x4be083[_0xdb41('0x46')];if(!_0x45fdf8['query']['hasOwnProperty']('nolimit')){_0x2d0cdf['limit']=qs[_0xdb41('0x33')](_0x45fdf8[_0xdb41('0x49')][_0xdb41('0x33')]);_0x2d0cdf[_0xdb41('0x31')]=qs[_0xdb41('0x31')](_0x45fdf8['query']['offset']);}_0x2d0cdf[_0xdb41('0x4f')]=qs[_0xdb41('0x50')](_0x45fdf8['query'][_0xdb41('0x50')]);_0x2d0cdf['where']=qs['filters'](_[_0xdb41('0x52')](_0x45fdf8['query'],_0x4be083[_0xdb41('0x51')]));_0x2d0cdf[_0xdb41('0x55')][_0xdb41('0x6b')]=_0x14b6f3['id'];if(_0x45fdf8[_0xdb41('0x49')][_0xdb41('0x53')]){_0x2d0cdf[_0xdb41('0x55')]=_[_0xdb41('0x54')](_0x2d0cdf['where'],{'$or':_['map'](_0x2d0cdf['attributes'],function(_0xd07c7c){var _0xf9ee0f={};_0xf9ee0f[_0xd07c7c]={'$like':'%'+_0x45fdf8[_0xdb41('0x49')][_0xdb41('0x53')]+'%'};return _0xf9ee0f;})});}if(_0x45fdf8[_0xdb41('0x49')][_0xdb41('0xa5')]){var _0x2b7630=_0x45fdf8[_0xdb41('0x49')][_0xdb41('0xa5')]['split'](',');var _0x4752de={};_0x4752de[_0x2b7630[0x0]]={'$gte':moment(_0x2b7630[0x1])['format'](_0xdb41('0xa6'))};_0x2d0cdf['where']=_[_0xdb41('0x54')](_0x2d0cdf[_0xdb41('0x55')],_0x4752de);}_0x2d0cdf=_[_0xdb41('0x54')]({},_0x2d0cdf,_0x45fdf8[_0xdb41('0x5f')]);return db['FaxMessage'][_0xdb41('0x34')]({'where':_0x2d0cdf[_0xdb41('0x55')]})[_0xdb41('0x21')](function(_0x2d2037){_0x5abfa8[_0xdb41('0x34')]=_0x2d2037;if(_0x45fdf8[_0xdb41('0x49')]['includeAll']){_0x2d0cdf[_0xdb41('0x5e')]=[{'all':!![]}];}return db['FaxMessage'][_0xdb41('0x57')](_0x2d0cdf);})[_0xdb41('0x21')](function(_0x23f2cc){_0x5abfa8[_0xdb41('0x58')]=_0x23f2cc;return _0x5abfa8;});}})[_0xdb41('0x21')](respondWithFilteredResult(_0x674676,_0x2d0cdf))[_0xdb41('0x2c')](handleError(_0x674676,null));};exports[_0xdb41('0x3e')]=function(_0x51467c,_0x18fe92,_0x10b500){var _0x5b2076,_0x4f611d={},_0x9c0315;if(_0x51467c[_0xdb41('0x61')]['to']){_0x9c0315=_0x51467c[_0xdb41('0x61')]['to'][0x0];}return db[_0xdb41('0x41')][_0xdb41('0x66')]({'where':{'id':_0x51467c[_0xdb41('0x5a')]['id']},'include':[{'model':db[_0xdb41('0xa7')],'as':_0xdb41('0xa8'),'include':[{'model':db[_0xdb41('0x77')],'as':'Contacts','where':{'fax':_0x9c0315},'limit':0x1,'order':[[_0xdb41('0xa0'),'DESC']]}]}]})[_0xdb41('0x21')](handleEntityNotFound(_0x18fe92,null))[_0xdb41('0x21')](function(_0x1551e5){_0x5b2076=_0x1551e5;if(_0x51467c['body'][_0xdb41('0xa9')]&&_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][_0xdb41('0x5c')]){for(var _0x14c4bf=0x0;_0x14c4bf<_0x51467c['body']['attachments'][_0xdb41('0x5c')];_0x14c4bf+=0x1){_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][_0x14c4bf]={'filename':_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][_0x14c4bf][_0xdb41('0x3d')],'id':_0x51467c['body'][_0xdb41('0xa9')][_0x14c4bf]['id'],'path':path[_0xdb41('0xaa')](config[_0xdb41('0xab')],_0xdb41('0xac'),_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][_0x14c4bf][_0xdb41('0xad')])};}}return respondWithRpcPromise('CheckAfterSend',_0xdb41('0xae'),{'FaxAccountId':_[_0xdb41('0xaf')](_0x51467c[_0xdb41('0x5a')]['id'])?undefined:_0x51467c['params']['id'],'path':_['isNil'](_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][0x0]['path'])?undefined:_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][0x0]['path'],'fax':_[_0xdb41('0xaf')](_0x51467c[_0xdb41('0x61')]['to'][0x0])?undefined:_0x51467c['body']['to'][0x0]},client9002);})[_0xdb41('0x21')](function(){if(_0x5b2076){if(_[_0xdb41('0xaf')](_0x51467c[_0xdb41('0x61')]['from'])){_0x51467c[_0xdb41('0x61')]['from']=util[_0xdb41('0xb0')]('\x22%s\x22\x20<%s>',_0x5b2076['name'],_0x5b2076[_0xdb41('0xb1')]);}if(_0x5b2076['List']){if(_0x5b2076[_0xdb41('0xa8')][_0xdb41('0xb2')][_0xdb41('0x5c')]){return _0x5b2076[_0xdb41('0xa8')][_0xdb41('0xb2')][0x0];}else{return db[_0xdb41('0x77')][_0xdb41('0x60')](_[_0xdb41('0x19')](_0x51467c[_0xdb41('0x61')],{'firstName':_0x51467c['body']['to'][0x0],'phone':_0x51467c[_0xdb41('0x61')]['to'][0x0],'fax':_0x51467c[_0xdb41('0x61')]['to'][0x0],'ListId':_0x5b2076[_0xdb41('0xa1')]}));}}else{throw new Error(_0xdb41('0xb3'));}}else{throw new Error(_0xdb41('0xb4'));}})[_0xdb41('0x21')](function(_0x1141df){if(_0x1141df){return db['FaxInteraction'][_0xdb41('0x66')]({'where':{'ContactId':_0x1141df['id'],'closed':![],'FaxAccountId':_0x5b2076['id']}})[_0xdb41('0x21')](function(_0x5f613c){if(_0x5f613c){return[_0x5f613c,![]];}return db['FaxInteraction'][_0xdb41('0x60')]({'UserId':_0x51467c[_0xdb41('0x62')]['id'],'ContactId':_0x1141df['id'],'FaxAccountId':_0x5b2076['id'],'fax':_0x51467c[_0xdb41('0x61')]['to'][0x0],'firstMsgDirection':_0xdb41('0xb5'),'Messages':[_[_0xdb41('0x54')](_0x51467c[_0xdb41('0x61')],{'read':![],'body':_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][0x0][_0xdb41('0xb6')],'FaxAccountId':_0x5b2076['id'],'UserId':_0x51467c['user']['id'],'ContactId':_0x1141df['id'],'AttachmentId':_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][0x0]['id']})]},{'include':[{'model':db[_0xdb41('0xa4')],'as':_0xdb41('0xb7')}]})[_0xdb41('0x21')](function(_0x3b12e6){return[_0x3b12e6,!![]];});});}else{throw new Error(_0xdb41('0xb8'));}})[_0xdb41('0xb9')](function(_0x267768,_0x4b30d8){if(_0x4b30d8){return _0x267768;}return db[_0xdb41('0xa4')][_0xdb41('0x60')]({'direction':_0xdb41('0xb5'),'read':![],'body':_0x51467c[_0xdb41('0x61')]['attachments'][0x0]['filename'],'FaxAccountId':_0x5b2076['id'],'FaxInteractionId':_0x267768['id'],'UserId':_0x51467c['user']['id'],'ContactId':_0x267768['ContactId'],'AttachmentId':_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][0x0]['id']})[_0xdb41('0x21')](function(_0xa7ccb9){_0x267768['dataValues'][_0xdb41('0xb7')]=[];_0x267768['dataValues'][_0xdb41('0xb7')][_0xdb41('0x91')](_0xa7ccb9[_0xdb41('0xba')]);return _0x267768;});})[_0xdb41('0x21')](function(_0x16196b){respondWithRpcPromise('SendFax',_0xdb41('0xbb'),{'FaxAccountId':_[_0xdb41('0xaf')](_0x51467c['params']['id'])?undefined:_0x51467c['params']['id'],'path':_[_0xdb41('0xaf')](_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][0x0][_0xdb41('0x7')])?undefined:_0x51467c['body'][_0xdb41('0xa9')][0x0][_0xdb41('0x7')],'fax':_[_0xdb41('0xaf')](_0x51467c[_0xdb41('0x61')]['to'][0x0])?undefined:_0x51467c['body']['to'][0x0],'AttachmentId':_0x51467c[_0xdb41('0x61')][_0xdb41('0xa9')][0x0]['id']},client9002)['then'](function(_0x1dcf2e){logger['info'](_0xdb41('0xbc'),_0x1dcf2e);})[_0xdb41('0x2c')](function(_0x1234e7){logger[_0xdb41('0x22')](_0xdb41('0xbc'),_0x1234e7);});return _0x16196b;})[_0xdb41('0x21')](respondWithResult(_0x18fe92,null))['catch'](handleError(_0x18fe92,null));};exports['addAgents']=function(_0x276c45,_0x2e8868,_0x57ac01){return db[_0xdb41('0x41')][_0xdb41('0x66')]({'where':{'id':_0x276c45[_0xdb41('0x5a')]['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x2e8868,null))['then'](function(_0x5edc33){if(_0x5edc33){return _0x5edc33['addAgents'](_0x276c45[_0xdb41('0x61')][_0xdb41('0x70')],_[_0xdb41('0x76')](_0x276c45[_0xdb41('0x61')],[_0xdb41('0x70'),'id'])||{})[_0xdb41('0xb9')](function(_0x4b84de){for(var _0x5d18bb=0x0;_0x5d18bb<_0x276c45[_0xdb41('0x61')][_0xdb41('0x70')][_0xdb41('0x5c')];_0x5d18bb+=0x1){socket[_0xdb41('0xbd')]('userFaxAccount:save',{'UserId':Number(_0x276c45[_0xdb41('0x61')][_0xdb41('0x70')][_0x5d18bb]),'FaxAccountId':Number(_0x276c45[_0xdb41('0x5a')]['id'])});}return _0x4b84de;});}})[_0xdb41('0x21')](respondWithResult(_0x2e8868,null))[_0xdb41('0x2c')](handleError(_0x2e8868,null));};exports[_0xdb41('0xbe')]=function(_0x8f1edd,_0xf0cc1,_0x432c9c){return db[_0xdb41('0x41')]['find']({'where':{'id':_0x8f1edd[_0xdb41('0x5a')]['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0xf0cc1,null))[_0xdb41('0x21')](function(_0x485a7d){if(_0x485a7d){return _0x485a7d[_0xdb41('0xbe')](_0x8f1edd['query'][_0xdb41('0x70')])[_0xdb41('0x21')](function(){if(_['isArray'](_0x8f1edd[_0xdb41('0x49')][_0xdb41('0x70')])){for(var _0x5d4451=0x0;_0x5d4451<_0x8f1edd['query'][_0xdb41('0x70')][_0xdb41('0x5c')];_0x5d4451+=0x1){socket[_0xdb41('0xbd')](_0xdb41('0xbf'),{'UserId':Number(_0x8f1edd[_0xdb41('0x49')][_0xdb41('0x70')][_0x5d4451]),'FaxAccountId':Number(_0x8f1edd[_0xdb41('0x5a')]['id'])});}}else{socket[_0xdb41('0xbd')]('userFaxAccount:remove',{'UserId':Number(_0x8f1edd[_0xdb41('0x49')][_0xdb41('0x70')]),'FaxAccountId':Number(_0x8f1edd[_0xdb41('0x5a')]['id'])});}});}})[_0xdb41('0x21')](respondWithStatusCode(_0xf0cc1,null))[_0xdb41('0x2c')](handleError(_0xf0cc1,null));};exports['getAgents']=function(_0x4ece90,_0x42b292,_0x5845f0){var _0x546e18={};var _0x13c354={};var _0x4eed66;var _0x412f95;return db[_0xdb41('0x41')][_0xdb41('0x6d')]({'where':{'id':_0x4ece90['params']['id']}})[_0xdb41('0x21')](handleEntityNotFound(_0x42b292,null))[_0xdb41('0x21')](function(_0x440780){if(_0x440780){_0x4eed66=_0x440780;_0x13c354[_0xdb41('0x46')]=_[_0xdb41('0x48')](db[_0xdb41('0xc0')][_0xdb41('0x42')]);_0x13c354[_0xdb41('0x49')]=_[_0xdb41('0x48')](_0x4ece90['query']);_0x13c354[_0xdb41('0x51')]=_[_0xdb41('0x4a')](_0x13c354[_0xdb41('0x46')],_0x13c354['query']);_0x546e18[_0xdb41('0x4c')]=_['intersection'](_0x13c354[_0xdb41('0x46')],qs[_0xdb41('0x4b')](_0x4ece90[_0xdb41('0x49')][_0xdb41('0x4b')]));_0x546e18[_0xdb41('0x4c')]=_0x546e18['attributes'][_0xdb41('0x5c')]?_0x546e18[_0xdb41('0x4c')]:_0x13c354[_0xdb41('0x46')];_0x546e18[_0xdb41('0x4f')]=qs[_0xdb41('0x50')](_0x4ece90[_0xdb41('0x49')][_0xdb41('0x50')]);_0x546e18[_0xdb41('0x55')]=qs[_0xdb41('0x51')](_[_0xdb41('0x52')](_0x4ece90[_0xdb41('0x49')],_0x13c354[_0xdb41('0x51')]));if(_0x4ece90['query'][_0xdb41('0x53')]){_0x546e18['where']=_[_0xdb41('0x54')](_0x546e18[_0xdb41('0x55')],{'$or':_[_0xdb41('0x47')](_0x546e18['attributes'],function(_0x46829e){var _0xf876e={};_0xf876e[_0x46829e]={'$like':'%'+_0x4ece90['query'][_0xdb41('0x53')]+'%'};return _0xf876e;})});}_0x546e18=_[_0xdb41('0x54')]({},_0x546e18,_0x4ece90[_0xdb41('0x5f')]);return _0x4eed66['getAgents'](_0x546e18);}})[_0xdb41('0x21')](function(_0x1ffea8){if(_0x1ffea8){_0x412f95=_0x1ffea8[_0xdb41('0x5c')];if(!_0x4ece90['query'][_0xdb41('0x4d')](_0xdb41('0x4e'))){_0x546e18[_0xdb41('0x33')]=qs[_0xdb41('0x33')](_0x4ece90['query'][_0xdb41('0x33')]);_0x546e18['offset']=qs[_0xdb41('0x31')](_0x4ece90[_0xdb41('0x49')]['offset']);}return _0x4eed66[_0xdb41('0xc1')](_0x546e18);}})[_0xdb41('0x21')](function(_0x47bd01){if(_0x47bd01){return _0x47bd01?{'count':_0x412f95,'rows':_0x47bd01}:null;}})[_0xdb41('0x21')](respondWithResult(_0x42b292,null))[_0xdb41('0x2c')](handleError(_0x42b292,null));};
\ No newline at end of file