Built motion from commit (unavailable).|2.5.28
[motion2.git] / server / api / faxAccount / faxAccount.controller.js
index c29d99c..f40c61e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x92f0=['addDisposition','getDispositions','findOne','sort','Disposition','findAll','removeDispositions','ids','addAnswer','CannedAnswer','FaxAccountId','removeAnswers','addInteraction','FaxInteraction','omit','getInteractions','CmContact','User','Owner','internal','Tag','Tags','tag','addApplications','sequelize','transaction','FaxApplication','bulkCreate','findAndCountAll','priority','getApplications','from-voip-provider','exten','app','system','Fax\x20Extension','appdata','push','Answer','CDR(type)=inbound-fax','Set','ecm','localstationid','gateway','faxdetect','headerinfo','minrate','Wait','addAccountApplications','VoiceExtension','tech','key','TrunkId','ListId','getMessages','FaxMessage','$gte','split','format','CmList','List','updatedAt','DESC','attachments','root','server/files/attachments','basename','CheckAfterSend','isNil','\x22%s\x22\x20<%s>','fax','List\x20not\x20found','Send\x20Fax\x20failed','out','filename','Messages','Contact\x20not\x20found','spread','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','emit','removeAgents','isArray','userFaxAccount:remove','getAgents','eml-format','rimraf','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','ejs','squel','jsforce','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','register','jayson/promise','client','http','request','then','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','FaxAccount,\x20%s,\x20%s','info','result','catch','sendStatus','end','count','offset','limit','status','set','save','destroy','get','FaxAccounts','name','send','index','Pause','mandatoryDispositionPause','map','FaxAccount','rawAttributes','fieldName','type','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','pick','filter','merge','options','includeAll','include','rows','show','params','find','create','body','user','role','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe'];(function(_0x5e173a,_0x5e0b6e){var _0x455846=function(_0x4a321e){while(--_0x4a321e){_0x5e173a['push'](_0x5e173a['shift']());}};_0x455846(++_0x5e0b6e);}(_0x92f0,0x10d));var _0x092f=function(_0x302b5e,_0x564a8e){_0x302b5e=_0x302b5e-0x0;var _0x523ab7=_0x92f0[_0x302b5e];return _0x523ab7;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x092f('0x0'));var rimraf=require(_0x092f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x092f('0x2'));var rp=require(_0x092f('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x092f('0x4'));var util=require(_0x092f('0x5'));var path=require(_0x092f('0x6'));var sox=require(_0x092f('0x7'));var csv=require(_0x092f('0x8'));var ejs=require(_0x092f('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x092f('0xa'));var crypto=require('crypto');var jsforce=require(_0x092f('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x092f('0x8'));var querystring=require('querystring');var Papa=require(_0x092f('0xc'));var Redis=require('ioredis');var authService=require(_0x092f('0xd'));var qs=require(_0x092f('0xe'));var as=require(_0x092f('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x092f('0x10'))(_0x092f('0x11'));var utils=require(_0x092f('0x12'));var config=require(_0x092f('0x13'));var licenseUtil=require(_0x092f('0x14'));var db=require('../../mysqldb')['db'];config[_0x092f('0x15')]=_[_0x092f('0x16')](config['redis'],{'host':_0x092f('0x17'),'port':0x18eb});var socket=require(_0x092f('0x18'))(new Redis(config[_0x092f('0x15')]));require(_0x092f('0x19'))[_0x092f('0x1a')](socket);var jayson=require(_0x092f('0x1b'));var client=jayson[_0x092f('0x1c')][_0x092f('0x1d')]({'port':0x232c});var client9002=jayson['client'][_0x092f('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x346c68,_0x33b0c0,_0x212e99,_0x57e911){return new BPromise(function(_0x530214,_0x6486db){var _0x103cae=_0x57e911||client;return _0x103cae[_0x092f('0x1e')](_0x346c68,_0x212e99)[_0x092f('0x1f')](function(_0x1711e2){logger['info']('FaxAccount,\x20%s,\x20%s',_0x33b0c0,_0x092f('0x20'));logger[_0x092f('0x21')](_0x092f('0x22'),_0x33b0c0,_0x092f('0x20'),JSON[_0x092f('0x23')](_0x1711e2));if(_0x1711e2['error']){if(_0x1711e2[_0x092f('0x24')]['code']===0x1f4){logger['error']('FaxAccount,\x20%s,\x20%s',_0x33b0c0,_0x1711e2[_0x092f('0x24')]['message']);return _0x6486db(_0x1711e2['error'][_0x092f('0x25')]);}logger[_0x092f('0x24')](_0x092f('0x26'),_0x33b0c0,_0x1711e2['error'][_0x092f('0x25')]);return _0x530214(_0x1711e2['error'][_0x092f('0x25')]);}else{logger[_0x092f('0x27')](_0x092f('0x26'),_0x33b0c0,_0x092f('0x20'));_0x530214(_0x1711e2[_0x092f('0x28')][_0x092f('0x25')]);}})[_0x092f('0x29')](function(_0x2932c2){logger[_0x092f('0x24')](_0x092f('0x26'),_0x33b0c0,_0x2932c2);_0x6486db(_0x2932c2);});});}function respondWithStatusCode(_0x27004c,_0x43f5c0){_0x43f5c0=_0x43f5c0||0xcc;return function(_0x29ac64){if(_0x29ac64){return _0x27004c[_0x092f('0x2a')](_0x43f5c0);}return _0x27004c['status'](_0x43f5c0)[_0x092f('0x2b')]();};}function respondWithResult(_0x459140,_0x58a5a7){_0x58a5a7=_0x58a5a7||0xc8;return function(_0x32f0a8){if(_0x32f0a8){return _0x459140['status'](_0x58a5a7)['json'](_0x32f0a8);}};}function respondWithFilteredResult(_0xea4c6,_0x282d53){return function(_0x32bc9f){if(_0x32bc9f){var _0x41a3b4=_0x32bc9f[_0x092f('0x2c')],_0x4c9cd0=_0x282d53[_0x092f('0x2d')],_0x301f10=_0x282d53[_0x092f('0x2d')]+_0x282d53[_0x092f('0x2e')],_0x55f71b;if(_0x301f10>=_0x41a3b4){_0x301f10=_0x41a3b4;_0x55f71b=0xc8;}else{_0x55f71b=0xce;}_0xea4c6[_0x092f('0x2f')](_0x55f71b);return _0xea4c6[_0x092f('0x30')]('Content-Range',_0x4c9cd0+'-'+_0x301f10+'/'+_0x41a3b4)['json'](_0x32bc9f);}return null;};}function patchUpdates(_0x4f74c8){return function(_0x23aea7){try{jsonpatch['apply'](_0x23aea7,_0x4f74c8,!![]);}catch(_0x1e59c8){return BPromise['reject'](_0x1e59c8);}return _0x23aea7[_0x092f('0x31')]();};}function saveUpdates(_0xa97ece,_0x5a0b57){return function(_0x2c4c69){if(_0x2c4c69){return _0x2c4c69['update'](_0xa97ece)[_0x092f('0x1f')](function(_0xc6d2cf){return _0xc6d2cf;});}return null;};}function removeEntity(_0x533959,_0x2f697f){return function(_0x46beb2){if(_0x46beb2){return _0x46beb2[_0x092f('0x32')]()['then'](function(){var _0x1b6f41=_0x46beb2[_0x092f('0x33')]({'plain':!![]});var _0x3beaad=_0x092f('0x34');return db['UserProfileResource'][_0x092f('0x32')]({'where':{'type':_0x3beaad,'resourceId':_0x1b6f41['id']}})[_0x092f('0x1f')](function(){return _0x46beb2;});})[_0x092f('0x1f')](function(){_0x533959['status'](0xcc)[_0x092f('0x2b')]();});}};}function handleEntityNotFound(_0x3a842e,_0x1e1807){return function(_0x45447e){if(!_0x45447e){_0x3a842e[_0x092f('0x2a')](0x194);}return _0x45447e;};}function handleError(_0x4029a7,_0x3f447b){_0x3f447b=_0x3f447b||0x1f4;return function(_0x3bb841){logger['error'](_0x3bb841['stack']);if(_0x3bb841[_0x092f('0x35')]){delete _0x3bb841['name'];}_0x4029a7[_0x092f('0x2f')](_0x3f447b)[_0x092f('0x36')](_0x3bb841);};}exports[_0x092f('0x37')]=function(_0x284017,_0x109b29){var _0x3eabb9={'include':[{'model':db[_0x092f('0x38')],'as':_0x092f('0x39')}]},_0x496ade={},_0x17944a={'count':0x0,'rows':[]};var _0x42f3a0=_[_0x092f('0x3a')](db[_0x092f('0x3b')][_0x092f('0x3c')],function(_0x9fa57){return{'name':_0x9fa57[_0x092f('0x3d')],'type':_0x9fa57[_0x092f('0x3e')]['key']};});_0x496ade[_0x092f('0x3f')]=_['map'](_0x42f3a0,'name');_0x496ade['query']=_[_0x092f('0x40')](_0x284017[_0x092f('0x41')]);_0x496ade[_0x092f('0x42')]=_[_0x092f('0x43')](_0x496ade[_0x092f('0x3f')],_0x496ade[_0x092f('0x41')]);_0x3eabb9[_0x092f('0x44')]=_['intersection'](_0x496ade['model'],qs[_0x092f('0x45')](_0x284017['query'][_0x092f('0x45')]));_0x3eabb9[_0x092f('0x44')]=_0x3eabb9['attributes'][_0x092f('0x46')]?_0x3eabb9[_0x092f('0x44')]:_0x496ade[_0x092f('0x3f')];if(!_0x284017[_0x092f('0x41')][_0x092f('0x47')](_0x092f('0x48'))){_0x3eabb9[_0x092f('0x2e')]=qs[_0x092f('0x2e')](_0x284017['query'][_0x092f('0x2e')]);_0x3eabb9[_0x092f('0x2d')]=qs[_0x092f('0x2d')](_0x284017[_0x092f('0x41')][_0x092f('0x2d')]);}_0x3eabb9[_0x092f('0x49')]=qs['sort'](_0x284017[_0x092f('0x41')]['sort']);_0x3eabb9[_0x092f('0x4a')]=qs[_0x092f('0x42')](_[_0x092f('0x4b')](_0x284017[_0x092f('0x41')],_0x496ade[_0x092f('0x42')]),_0x42f3a0);if(_0x284017['query'][_0x092f('0x4c')]){_0x3eabb9['where']=_[_0x092f('0x4d')](_0x3eabb9[_0x092f('0x4a')],{'$or':_[_0x092f('0x3a')](_0x42f3a0,function(_0x44f43a){if(_0x44f43a['type']!=='VIRTUAL'){var _0x2e7f78={};_0x2e7f78[_0x44f43a['name']]={'$like':'%'+_0x284017[_0x092f('0x41')][_0x092f('0x4c')]+'%'};return _0x2e7f78;}})});}_0x3eabb9=_['merge']({},_0x3eabb9,_0x284017[_0x092f('0x4e')]);var _0x6b9cb6={'where':_0x3eabb9[_0x092f('0x4a')]};return db[_0x092f('0x3b')][_0x092f('0x2c')](_0x6b9cb6)[_0x092f('0x1f')](function(_0x4ca428){_0x17944a[_0x092f('0x2c')]=_0x4ca428;if(_0x284017[_0x092f('0x41')][_0x092f('0x4f')]){_0x3eabb9[_0x092f('0x50')]=[{'all':!![]}];}return db[_0x092f('0x3b')]['findAll'](_0x3eabb9);})['then'](function(_0x15b795){_0x17944a[_0x092f('0x51')]=_0x15b795;return _0x17944a;})[_0x092f('0x1f')](respondWithFilteredResult(_0x109b29,_0x3eabb9))['catch'](handleError(_0x109b29,null));};exports[_0x092f('0x52')]=function(_0x3bf0a1,_0x19bb9a){var _0x2df933={'raw':![],'where':{'id':_0x3bf0a1[_0x092f('0x53')]['id']},'include':[{'model':db[_0x092f('0x38')],'as':'mandatoryDispositionPause'}]},_0x13f3c4={};_0x13f3c4[_0x092f('0x3f')]=_[_0x092f('0x40')](db[_0x092f('0x3b')][_0x092f('0x3c')]);_0x13f3c4[_0x092f('0x41')]=_[_0x092f('0x40')](_0x3bf0a1[_0x092f('0x41')]);_0x13f3c4['filters']=_[_0x092f('0x43')](_0x13f3c4[_0x092f('0x3f')],_0x13f3c4[_0x092f('0x41')]);_0x2df933[_0x092f('0x44')]=_['intersection'](_0x13f3c4[_0x092f('0x3f')],qs[_0x092f('0x45')](_0x3bf0a1['query'][_0x092f('0x45')]));_0x2df933['attributes']=_0x2df933[_0x092f('0x44')][_0x092f('0x46')]?_0x2df933[_0x092f('0x44')]:_0x13f3c4['model'];if(_0x3bf0a1['query'][_0x092f('0x4f')]){_0x2df933[_0x092f('0x50')]=[{'all':!![]}];}_0x2df933=_[_0x092f('0x4d')]({},_0x2df933,_0x3bf0a1[_0x092f('0x4e')]);return db[_0x092f('0x3b')][_0x092f('0x54')](_0x2df933)['then'](handleEntityNotFound(_0x19bb9a,null))[_0x092f('0x1f')](respondWithResult(_0x19bb9a,null))[_0x092f('0x29')](handleError(_0x19bb9a,null));};exports[_0x092f('0x55')]=function(_0x58d82d,_0x5b098a){return db[_0x092f('0x3b')]['create'](_0x58d82d[_0x092f('0x56')],{})[_0x092f('0x1f')](function(_0x3d488b){var _0x36fae3=_0x58d82d[_0x092f('0x57')][_0x092f('0x33')]({'plain':!![]});if(!_0x36fae3)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x36fae3[_0x092f('0x58')]===_0x092f('0x57')){var _0x44386e=_0x3d488b['get']({'plain':!![]});var _0x6ab5d2='FaxAccounts';return db['UserProfileSection']['find']({'where':{'name':_0x6ab5d2,'userProfileId':_0x36fae3[_0x092f('0x59')]},'raw':!![]})[_0x092f('0x1f')](function(_0xf67402){if(_0xf67402&&_0xf67402[_0x092f('0x5a')]===0x0){return db[_0x092f('0x5b')][_0x092f('0x55')]({'name':_0x44386e[_0x092f('0x35')],'resourceId':_0x44386e['id'],'type':_0xf67402[_0x092f('0x35')],'sectionId':_0xf67402['id']},{})['then'](function(){return _0x3d488b;});}else{return _0x3d488b;}})[_0x092f('0x29')](function(_0x1485c4){logger[_0x092f('0x24')](_0x092f('0x5c'),_0x1485c4);throw _0x1485c4;});}return _0x3d488b;})['then'](respondWithResult(_0x5b098a,0xc9))[_0x092f('0x29')](handleError(_0x5b098a,null));};exports[_0x092f('0x5d')]=function(_0x40131e,_0xc296e4){if(_0x40131e[_0x092f('0x56')]['id']){delete _0x40131e['body']['id'];}return db[_0x092f('0x3b')][_0x092f('0x54')]({'where':{'id':_0x40131e[_0x092f('0x53')]['id']},'include':[{'model':db[_0x092f('0x38')],'as':_0x092f('0x39')}]})[_0x092f('0x1f')](handleEntityNotFound(_0xc296e4,null))['then'](saveUpdates(_0x40131e[_0x092f('0x56')],null))[_0x092f('0x1f')](respondWithResult(_0xc296e4,null))[_0x092f('0x29')](handleError(_0xc296e4,null));};exports[_0x092f('0x32')]=function(_0x5053db,_0x24d511){return db[_0x092f('0x3b')][_0x092f('0x54')]({'where':{'id':_0x5053db[_0x092f('0x53')]['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x24d511,null))[_0x092f('0x1f')](removeEntity(_0x24d511,null))['catch'](handleError(_0x24d511,null));};exports[_0x092f('0x5e')]=function(_0x521f83,_0x29ffc3){return db[_0x092f('0x3b')]['describe']()[_0x092f('0x1f')](respondWithResult(_0x29ffc3,null))['catch'](handleError(_0x29ffc3,null));};exports[_0x092f('0x5f')]=function(_0x16c622,_0x1d9245,_0x2a6de1){if(_0x16c622[_0x092f('0x56')]['id']){delete _0x16c622[_0x092f('0x56')]['id'];}return db[_0x092f('0x3b')][_0x092f('0x54')]({'where':{'id':_0x16c622['params']['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x1d9245,null))[_0x092f('0x1f')](function(_0x383bff){if(_0x383bff){_0x16c622[_0x092f('0x56')]['FaxAccountId']=_0x383bff['id'];return db['Disposition'][_0x092f('0x55')](_0x16c622[_0x092f('0x56')]);}})[_0x092f('0x1f')](respondWithResult(_0x1d9245,null))[_0x092f('0x29')](handleError(_0x1d9245,null));};exports[_0x092f('0x60')]=function(_0xf0dff3,_0x2f4983,_0x59ca53){var _0x2cf40e={'raw':![],'where':{}};var _0x431ded={};var _0x1911a8={'count':0x0,'rows':[]};return db[_0x092f('0x3b')][_0x092f('0x61')]({'where':{'id':_0xf0dff3[_0x092f('0x53')]['id']}})['then'](handleEntityNotFound(_0x2f4983,null))[_0x092f('0x1f')](function(_0x54fb52){if(_0x54fb52){_0x431ded[_0x092f('0x3f')]=_[_0x092f('0x40')](db['Disposition'][_0x092f('0x3c')]);_0x431ded[_0x092f('0x41')]=_[_0x092f('0x40')](_0xf0dff3[_0x092f('0x41')]);_0x431ded['filters']=_['intersection'](_0x431ded[_0x092f('0x3f')],_0x431ded[_0x092f('0x41')]);_0x2cf40e[_0x092f('0x44')]=_['intersection'](_0x431ded[_0x092f('0x3f')],qs[_0x092f('0x45')](_0xf0dff3[_0x092f('0x41')][_0x092f('0x45')]));_0x2cf40e[_0x092f('0x44')]=_0x2cf40e[_0x092f('0x44')][_0x092f('0x46')]?_0x2cf40e[_0x092f('0x44')]:_0x431ded['model'];if(!_0xf0dff3[_0x092f('0x41')][_0x092f('0x47')](_0x092f('0x48'))){_0x2cf40e[_0x092f('0x2e')]=qs[_0x092f('0x2e')](_0xf0dff3[_0x092f('0x41')]['limit']);_0x2cf40e[_0x092f('0x2d')]=qs[_0x092f('0x2d')](_0xf0dff3[_0x092f('0x41')]['offset']);}_0x2cf40e[_0x092f('0x49')]=qs['sort'](_0xf0dff3[_0x092f('0x41')][_0x092f('0x62')]);_0x2cf40e[_0x092f('0x4a')]=qs['filters'](_[_0x092f('0x4b')](_0xf0dff3[_0x092f('0x41')],_0x431ded['filters']));_0x2cf40e[_0x092f('0x4a')]['FaxAccountId']=_0x54fb52['id'];if(_0xf0dff3[_0x092f('0x41')]['filter']){_0x2cf40e[_0x092f('0x4a')]=_['merge'](_0x2cf40e['where'],{'$or':_[_0x092f('0x3a')](_0x2cf40e[_0x092f('0x44')],function(_0x4aad61){var _0x14d00f={};_0x14d00f[_0x4aad61]={'$like':'%'+_0xf0dff3[_0x092f('0x41')][_0x092f('0x4c')]+'%'};return _0x14d00f;})});}_0x2cf40e=_[_0x092f('0x4d')]({},_0x2cf40e,_0xf0dff3['options']);return db[_0x092f('0x63')][_0x092f('0x2c')]({'where':_0x2cf40e[_0x092f('0x4a')]})['then'](function(_0x53f353){_0x1911a8[_0x092f('0x2c')]=_0x53f353;if(_0xf0dff3[_0x092f('0x41')]['includeAll']){_0x2cf40e[_0x092f('0x50')]=[{'all':!![]}];}return db[_0x092f('0x63')][_0x092f('0x64')](_0x2cf40e);})[_0x092f('0x1f')](function(_0x9f597c){_0x1911a8[_0x092f('0x51')]=_0x9f597c;return _0x1911a8;});}})[_0x092f('0x1f')](respondWithFilteredResult(_0x2f4983,_0x2cf40e))[_0x092f('0x29')](handleError(_0x2f4983,null));};exports[_0x092f('0x65')]=function(_0xf5a28d,_0x5d92ca,_0x4d6808){return db[_0x092f('0x3b')][_0x092f('0x54')]({'where':{'id':_0xf5a28d['params']['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x5d92ca,null))[_0x092f('0x1f')](function(_0x134a19){if(_0x134a19){return _0x134a19[_0x092f('0x65')](_0xf5a28d[_0x092f('0x41')][_0x092f('0x66')]);}})[_0x092f('0x1f')](respondWithStatusCode(_0x5d92ca,null))[_0x092f('0x29')](handleError(_0x5d92ca,null));};exports[_0x092f('0x67')]=function(_0x395398,_0x1ad4e6,_0x640980){if(_0x395398[_0x092f('0x56')]['id']){delete _0x395398[_0x092f('0x56')]['id'];}return db[_0x092f('0x3b')][_0x092f('0x54')]({'where':{'id':_0x395398[_0x092f('0x53')]['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x1ad4e6,null))['then'](function(_0x27fb48){if(_0x27fb48){_0x395398[_0x092f('0x56')]['FaxAccountId']=_0x27fb48['id'];return db[_0x092f('0x68')]['create'](_0x395398[_0x092f('0x56')]);}})[_0x092f('0x1f')](respondWithResult(_0x1ad4e6,null))[_0x092f('0x29')](handleError(_0x1ad4e6,null));};exports['getAnswers']=function(_0x2abedd,_0xa34acd,_0xb2f768){var _0x15518e={'raw':![],'where':{}};var _0x39ef68={};var _0x2f7d01={'count':0x0,'rows':[]};return db[_0x092f('0x3b')]['findOne']({'where':{'id':_0x2abedd['params']['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0xa34acd,null))[_0x092f('0x1f')](function(_0x2158b3){if(_0x2158b3){_0x39ef68[_0x092f('0x3f')]=_[_0x092f('0x40')](db['CannedAnswer'][_0x092f('0x3c')]);_0x39ef68['query']=_[_0x092f('0x40')](_0x2abedd[_0x092f('0x41')]);_0x39ef68[_0x092f('0x42')]=_['intersection'](_0x39ef68[_0x092f('0x3f')],_0x39ef68['query']);_0x15518e[_0x092f('0x44')]=_[_0x092f('0x43')](_0x39ef68[_0x092f('0x3f')],qs[_0x092f('0x45')](_0x2abedd[_0x092f('0x41')][_0x092f('0x45')]));_0x15518e['attributes']=_0x15518e[_0x092f('0x44')][_0x092f('0x46')]?_0x15518e[_0x092f('0x44')]:_0x39ef68[_0x092f('0x3f')];if(!_0x2abedd[_0x092f('0x41')][_0x092f('0x47')](_0x092f('0x48'))){_0x15518e['limit']=qs[_0x092f('0x2e')](_0x2abedd[_0x092f('0x41')][_0x092f('0x2e')]);_0x15518e[_0x092f('0x2d')]=qs[_0x092f('0x2d')](_0x2abedd[_0x092f('0x41')]['offset']);}_0x15518e[_0x092f('0x49')]=qs[_0x092f('0x62')](_0x2abedd[_0x092f('0x41')][_0x092f('0x62')]);_0x15518e['where']=qs['filters'](_[_0x092f('0x4b')](_0x2abedd[_0x092f('0x41')],_0x39ef68['filters']));_0x15518e[_0x092f('0x4a')][_0x092f('0x69')]=_0x2158b3['id'];if(_0x2abedd[_0x092f('0x41')][_0x092f('0x4c')]){_0x15518e['where']=_[_0x092f('0x4d')](_0x15518e[_0x092f('0x4a')],{'$or':_[_0x092f('0x3a')](_0x15518e[_0x092f('0x44')],function(_0x3522e5){var _0x48b2ae={};_0x48b2ae[_0x3522e5]={'$like':'%'+_0x2abedd[_0x092f('0x41')][_0x092f('0x4c')]+'%'};return _0x48b2ae;})});}_0x15518e=_[_0x092f('0x4d')]({},_0x15518e,_0x2abedd[_0x092f('0x4e')]);return db['CannedAnswer'][_0x092f('0x2c')]({'where':_0x15518e[_0x092f('0x4a')]})[_0x092f('0x1f')](function(_0x1cb222){_0x2f7d01[_0x092f('0x2c')]=_0x1cb222;if(_0x2abedd[_0x092f('0x41')][_0x092f('0x4f')]){_0x15518e[_0x092f('0x50')]=[{'all':!![]}];}return db[_0x092f('0x68')]['findAll'](_0x15518e);})[_0x092f('0x1f')](function(_0x58a945){_0x2f7d01[_0x092f('0x51')]=_0x58a945;return _0x2f7d01;});}})[_0x092f('0x1f')](respondWithFilteredResult(_0xa34acd,_0x15518e))[_0x092f('0x29')](handleError(_0xa34acd,null));};exports[_0x092f('0x6a')]=function(_0x126e15,_0x1eb59f,_0x14985a){return db[_0x092f('0x3b')][_0x092f('0x54')]({'where':{'id':_0x126e15[_0x092f('0x53')]['id']}})['then'](handleEntityNotFound(_0x1eb59f,null))[_0x092f('0x1f')](function(_0x16a22a){if(_0x16a22a){return _0x16a22a[_0x092f('0x6a')](_0x126e15[_0x092f('0x41')][_0x092f('0x66')]);}})[_0x092f('0x1f')](respondWithStatusCode(_0x1eb59f,null))[_0x092f('0x29')](handleError(_0x1eb59f,null));};exports[_0x092f('0x6b')]=function(_0x3016da,_0x4f35e5,_0x1fc17b){return db[_0x092f('0x6c')][_0x092f('0x54')]({'where':{'id':_0x3016da[_0x092f('0x53')]['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x4f35e5,null))[_0x092f('0x1f')](function(_0xf68cd5){if(_0xf68cd5){return _0xf68cd5['addInteraction'](_0x3016da[_0x092f('0x56')]['ids'],_[_0x092f('0x6d')](_0x3016da['body'],[_0x092f('0x66'),'id'])||{});}})[_0x092f('0x1f')](respondWithResult(_0x4f35e5,null))[_0x092f('0x29')](handleError(_0x4f35e5,null));};exports[_0x092f('0x6e')]=function(_0x548f5f,_0xf54b3c,_0x494462){var _0x255fd3={'raw':![],'where':{}};var _0x4e83ce={};var _0x48d748={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x548f5f[_0x092f('0x53')]['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0xf54b3c,null))['then'](function(_0x41bef0){if(_0x41bef0){_0x4e83ce['model']=_[_0x092f('0x40')](db['FaxInteraction'][_0x092f('0x3c')]);_0x4e83ce[_0x092f('0x41')]=_[_0x092f('0x40')](_0x548f5f[_0x092f('0x41')]);_0x4e83ce[_0x092f('0x42')]=_[_0x092f('0x43')](_0x4e83ce[_0x092f('0x3f')],_0x4e83ce['query']);_0x255fd3['attributes']=_['intersection'](_0x4e83ce[_0x092f('0x3f')],qs['fields'](_0x548f5f['query'][_0x092f('0x45')]));_0x255fd3[_0x092f('0x44')]=_0x255fd3[_0x092f('0x44')][_0x092f('0x46')]?_0x255fd3[_0x092f('0x44')]:_0x4e83ce[_0x092f('0x3f')];if(!_0x548f5f[_0x092f('0x41')][_0x092f('0x47')]('nolimit')){_0x255fd3[_0x092f('0x2e')]=qs['limit'](_0x548f5f[_0x092f('0x41')][_0x092f('0x2e')]);_0x255fd3[_0x092f('0x2d')]=qs[_0x092f('0x2d')](_0x548f5f['query'][_0x092f('0x2d')]);}_0x255fd3[_0x092f('0x49')]=qs['sort'](_0x548f5f[_0x092f('0x41')]['sort']);_0x255fd3[_0x092f('0x4a')]=qs[_0x092f('0x42')](_[_0x092f('0x4b')](_0x548f5f[_0x092f('0x41')],_0x4e83ce[_0x092f('0x42')]));_0x255fd3[_0x092f('0x4a')][_0x092f('0x69')]=_0x41bef0['id'];if(_0x548f5f['query']['filter']){_0x255fd3[_0x092f('0x4a')]=_[_0x092f('0x4d')](_0x255fd3[_0x092f('0x4a')],{'$or':_[_0x092f('0x3a')](_0x255fd3[_0x092f('0x44')],function(_0x54cad9){var _0xd7e8ee={};_0xd7e8ee[_0x54cad9]={'$like':'%'+_0x548f5f[_0x092f('0x41')][_0x092f('0x4c')]+'%'};return _0xd7e8ee;})});}_0x255fd3=_[_0x092f('0x4d')]({},_0x255fd3,_0x548f5f[_0x092f('0x4e')]);return db[_0x092f('0x6c')][_0x092f('0x2c')]({'where':_0x255fd3['where']})['then'](function(_0x2ad31d){_0x48d748[_0x092f('0x2c')]=_0x2ad31d;if(_0x548f5f[_0x092f('0x41')][_0x092f('0x4f')]){_0x255fd3[_0x092f('0x50')]=[{'model':db[_0x092f('0x6f')],'as':'Contact','required':![]},{'model':db[_0x092f('0x70')],'as':_0x092f('0x71'),'attributes':[_0x092f('0x35'),'fullname',_0x092f('0x72')],'required':![]},{'model':db[_0x092f('0x73')],'as':_0x092f('0x74'),'attributes':['id',_0x092f('0x35'),'color'],'where':_0x548f5f[_0x092f('0x41')][_0x092f('0x75')]?{'id':_0x548f5f[_0x092f('0x41')]['tag']}:undefined,'required':_0x548f5f[_0x092f('0x41')][_0x092f('0x75')]?!![]:![]}];}return db['FaxInteraction'][_0x092f('0x64')](_0x255fd3);})[_0x092f('0x1f')](function(_0x104ef5){_0x48d748[_0x092f('0x51')]=_0x104ef5;return _0x48d748;});}})[_0x092f('0x1f')](respondWithFilteredResult(_0xf54b3c,_0x255fd3))[_0x092f('0x29')](handleError(_0xf54b3c,null));};exports[_0x092f('0x76')]=function(_0x89c6ad,_0x10aed6,_0x1a77b6){return db[_0x092f('0x3b')][_0x092f('0x61')]({'where':{'id':_0x89c6ad[_0x092f('0x53')]['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x10aed6,null))[_0x092f('0x1f')](function(_0x5daab1){if(_0x5daab1){return db[_0x092f('0x77')][_0x092f('0x78')](function(_0x1653e5){return db[_0x092f('0x79')]['destroy']({'where':{'FaxAccountId':_0x89c6ad['params']['id']},'transaction':_0x1653e5})[_0x092f('0x1f')](function(_0x1911ab){var _0xde2428=_[_0x092f('0x3a')](_0x89c6ad[_0x092f('0x56')],function(_0x5e5a09){_0x5e5a09['FaxAccountId']=_0x89c6ad['params']['id'];return _0x5e5a09;});return db['FaxApplication'][_0x092f('0x7a')](_0xde2428,{'transaction':_0x1653e5});});})[_0x092f('0x1f')](function(){return db[_0x092f('0x79')][_0x092f('0x7b')]({'where':{'FaxAccountId':_0x89c6ad[_0x092f('0x53')]['id']},'order':_0x092f('0x7c')});});}})[_0x092f('0x1f')](respondWithResult(_0x10aed6,null))[_0x092f('0x29')](handleError(_0x10aed6,null));};exports[_0x092f('0x7d')]=function(_0x2a87cc,_0x3e3e8b,_0x44a72c){var _0x379c96={};var _0x4d3657={};var _0x17a89d;var _0x29da6b;return db[_0x092f('0x3b')][_0x092f('0x61')]({'where':{'id':_0x2a87cc['params']['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x3e3e8b,null))[_0x092f('0x1f')](function(_0x3123b0){if(_0x3123b0){_0x17a89d=_0x3123b0;_0x4d3657[_0x092f('0x3f')]=_[_0x092f('0x40')](db[_0x092f('0x79')][_0x092f('0x3c')]);_0x4d3657[_0x092f('0x41')]=_['keys'](_0x2a87cc[_0x092f('0x41')]);_0x4d3657['filters']=_[_0x092f('0x43')](_0x4d3657[_0x092f('0x3f')],_0x4d3657[_0x092f('0x41')]);_0x379c96[_0x092f('0x44')]=_[_0x092f('0x43')](_0x4d3657[_0x092f('0x3f')],qs[_0x092f('0x45')](_0x2a87cc[_0x092f('0x41')][_0x092f('0x45')]));_0x379c96[_0x092f('0x44')]=_0x379c96[_0x092f('0x44')]['length']?_0x379c96[_0x092f('0x44')]:_0x4d3657[_0x092f('0x3f')];_0x379c96['order']=qs[_0x092f('0x62')](_0x2a87cc[_0x092f('0x41')][_0x092f('0x62')]);_0x379c96[_0x092f('0x4a')]=qs[_0x092f('0x42')](_[_0x092f('0x4b')](_0x2a87cc[_0x092f('0x41')],_0x4d3657[_0x092f('0x42')]));if(_0x2a87cc[_0x092f('0x41')]['filter']){_0x379c96['where']=_[_0x092f('0x4d')](_0x379c96[_0x092f('0x4a')],{'$or':_[_0x092f('0x3a')](_0x379c96[_0x092f('0x44')],function(_0x356308){var _0x135892={};_0x135892[_0x356308]={'$like':'%'+_0x2a87cc[_0x092f('0x41')][_0x092f('0x4c')]+'%'};return _0x135892;})});}_0x379c96=_[_0x092f('0x4d')]({},_0x379c96,_0x2a87cc[_0x092f('0x4e')]);return _0x17a89d['getApplications'](_0x379c96);}})[_0x092f('0x1f')](function(_0x362c11){if(_0x362c11){_0x29da6b=_0x362c11['length'];if(!_0x2a87cc['query'][_0x092f('0x47')](_0x092f('0x48'))){_0x379c96['limit']=qs[_0x092f('0x2e')](_0x2a87cc['query'][_0x092f('0x2e')]);_0x379c96['offset']=qs[_0x092f('0x2d')](_0x2a87cc[_0x092f('0x41')][_0x092f('0x2d')]);}return _0x17a89d[_0x092f('0x7d')](_0x379c96);}})[_0x092f('0x1f')](function(_0x501799){if(_0x501799){return _0x501799?{'count':_0x29da6b,'rows':_0x501799}:null;}})[_0x092f('0x1f')](respondWithResult(_0x3e3e8b,null))[_0x092f('0x29')](handleError(_0x3e3e8b,null));};function Extension(_0x381638,_0x40547b,_0xf5ed3f,_0x53afe7){this['context']=_0x092f('0x7e');this[_0x092f('0x7f')]=_0x381638['localstationid'];this[_0x092f('0x80')]=_0x53afe7;this[_0x092f('0x3e')]=_0x092f('0x81');this['description']=_0x092f('0x82');this[_0x092f('0x69')]=_0x381638['id'];this[_0x092f('0x7c')]=_0x40547b;this[_0x092f('0x83')]=_0xf5ed3f;}function createExtensionsReciveFax(_0x142be5){var _0x191be3=0x1;var _0x4d0eae=[];_0x4d0eae[_0x092f('0x84')](new Extension(_0x142be5,_0x191be3,'',_0x092f('0x85')));_0x191be3+=0x1;_0x4d0eae[_0x092f('0x84')](new Extension(_0x142be5,_0x191be3,_0x092f('0x86'),_0x092f('0x87')));_0x191be3+=0x1;for(var _0xa1c03d in _0x142be5){if(_0x142be5[_0x092f('0x47')](_0xa1c03d)&&(_0xa1c03d===_0x092f('0x88')||_0xa1c03d===_0x092f('0x89')||_0xa1c03d===_0x092f('0x8a')||_0xa1c03d===_0x092f('0x8b')||_0xa1c03d===_0x092f('0x8c')||_0xa1c03d==='maxrate'||_0xa1c03d===_0x092f('0x8d')||_0xa1c03d==='modem'||_0xa1c03d==='t38timeout')){_0x4d0eae[_0x092f('0x84')](new Extension(_0x142be5,_0x191be3,'FAXOPT('+_0xa1c03d+')='+_0x142be5[_0xa1c03d],_0x092f('0x87')));_0x191be3+=0x1;}}_0x4d0eae['push'](new Extension(_0x142be5,_0x191be3,'6',_0x092f('0x8e')));_0x191be3+=0x1;_0x4d0eae[_0x092f('0x84')](new Extension(_0x142be5,_0x191be3,'/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'));_0x191be3=0x0;return _0x4d0eae;}exports[_0x092f('0x8f')]=function(_0x735b42,_0x5ec450,_0x62f77a){var _0x1b2b81;return db['sequelize'][_0x092f('0x78')](function(_0xe2b021){return db[_0x092f('0x3b')][_0x092f('0x55')](_0x735b42[_0x092f('0x56')],{'transaction':_0xe2b021})['then'](function(_0x4aa29b){_0x1b2b81=_0x4aa29b[_0x092f('0x33')]({'plain':!![]});return db[_0x092f('0x90')][_0x092f('0x7a')](createExtensionsReciveFax(_0x1b2b81),{'transaction':_0xe2b021});});})[_0x092f('0x1f')](function(){return _0x1b2b81;})[_0x092f('0x1f')](respondWithResult(_0x5ec450,null))[_0x092f('0x29')](handleError(_0x5ec450,null));};exports['updateAccountApplications']=function(_0x43ccad,_0x1212a8,_0x355c07){var _0x5ddb88;return db[_0x092f('0x77')][_0x092f('0x78')](function(_0x260990){return db[_0x092f('0x3b')][_0x092f('0x5d')](_0x43ccad[_0x092f('0x56')],{'where':{'id':_0x43ccad[_0x092f('0x56')]['id']},'transaction':_0x260990})[_0x092f('0x1f')](function(_0x57efb5){return db[_0x092f('0x90')][_0x092f('0x32')]({'where':{'FaxAccountId':_0x43ccad[_0x092f('0x56')]['id']},'transaction':_0x260990})[_0x092f('0x1f')](function(_0x466162){return db[_0x092f('0x90')][_0x092f('0x7a')](createExtensionsReciveFax(_[_0x092f('0x6d')](_0x43ccad['body'],[_0x092f('0x91'),_0x092f('0x92'),'createdAt','updatedAt',_0x092f('0x93'),_0x092f('0x94')])),{'transaction':_0x260990});});});})[_0x092f('0x1f')](function(){return db['FaxAccount']['findById'](_0x43ccad[_0x092f('0x56')]['id']);})[_0x092f('0x1f')](respondWithResult(_0x1212a8,null))[_0x092f('0x29')](handleError(_0x1212a8,null));};exports[_0x092f('0x95')]=function(_0x54be45,_0x4215e9,_0x18ef61){var _0x37334e={'raw':!![],'where':{}};var _0x35ac76={};var _0x7c934={'count':0x0,'rows':[]};return db[_0x092f('0x3b')][_0x092f('0x61')]({'where':{'id':_0x54be45[_0x092f('0x53')]['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x4215e9,null))['then'](function(_0x147cbb){if(_0x147cbb){_0x35ac76['model']=_['keys'](db[_0x092f('0x96')][_0x092f('0x3c')]);_0x35ac76[_0x092f('0x41')]=_[_0x092f('0x40')](_0x54be45[_0x092f('0x41')]);_0x35ac76[_0x092f('0x42')]=_['intersection'](_0x35ac76[_0x092f('0x3f')],_0x35ac76['query']);_0x37334e[_0x092f('0x44')]=_[_0x092f('0x43')](_0x35ac76[_0x092f('0x3f')],qs[_0x092f('0x45')](_0x54be45[_0x092f('0x41')]['fields']));_0x37334e[_0x092f('0x44')]=_0x37334e[_0x092f('0x44')][_0x092f('0x46')]?_0x37334e[_0x092f('0x44')]:_0x35ac76[_0x092f('0x3f')];if(!_0x54be45['query'][_0x092f('0x47')](_0x092f('0x48'))){_0x37334e[_0x092f('0x2e')]=qs[_0x092f('0x2e')](_0x54be45[_0x092f('0x41')][_0x092f('0x2e')]);_0x37334e['offset']=qs[_0x092f('0x2d')](_0x54be45[_0x092f('0x41')][_0x092f('0x2d')]);}_0x37334e[_0x092f('0x49')]=qs[_0x092f('0x62')](_0x54be45[_0x092f('0x41')][_0x092f('0x62')]);_0x37334e[_0x092f('0x4a')]=qs[_0x092f('0x42')](_[_0x092f('0x4b')](_0x54be45[_0x092f('0x41')],_0x35ac76[_0x092f('0x42')]));_0x37334e[_0x092f('0x4a')][_0x092f('0x69')]=_0x147cbb['id'];if(_0x54be45['query']['filter']){_0x37334e['where']=_[_0x092f('0x4d')](_0x37334e[_0x092f('0x4a')],{'$or':_[_0x092f('0x3a')](_0x37334e[_0x092f('0x44')],function(_0x2c5fd4){var _0x384839={};_0x384839[_0x2c5fd4]={'$like':'%'+_0x54be45[_0x092f('0x41')]['filter']+'%'};return _0x384839;})});}if(_0x54be45[_0x092f('0x41')][_0x092f('0x97')]){var _0x3f4ab1=_0x54be45['query'][_0x092f('0x97')][_0x092f('0x98')](',');var _0x5098a9={};_0x5098a9[_0x3f4ab1[0x0]]={'$gte':moment(_0x3f4ab1[0x1])[_0x092f('0x99')]('YYYY-MM-DD\x20HH:mm:ss')};_0x37334e[_0x092f('0x4a')]=_[_0x092f('0x4d')](_0x37334e[_0x092f('0x4a')],_0x5098a9);}_0x37334e=_['merge']({},_0x37334e,_0x54be45['options']);return db[_0x092f('0x96')][_0x092f('0x2c')]({'where':_0x37334e['where']})[_0x092f('0x1f')](function(_0x57f296){_0x7c934[_0x092f('0x2c')]=_0x57f296;if(_0x54be45['query'][_0x092f('0x4f')]){_0x37334e[_0x092f('0x50')]=[{'all':!![]}];}return db[_0x092f('0x96')][_0x092f('0x64')](_0x37334e);})[_0x092f('0x1f')](function(_0x45d2d5){_0x7c934[_0x092f('0x51')]=_0x45d2d5;return _0x7c934;});}})['then'](respondWithFilteredResult(_0x4215e9,_0x37334e))[_0x092f('0x29')](handleError(_0x4215e9,null));};exports[_0x092f('0x36')]=function(_0x3ff364,_0x229d6e,_0x4471a5){var _0x42215b,_0x3c512d={},_0x22f0e5;if(_0x3ff364[_0x092f('0x56')]['to']){_0x22f0e5=_0x3ff364[_0x092f('0x56')]['to'][0x0];}return db[_0x092f('0x3b')]['find']({'where':{'id':_0x3ff364[_0x092f('0x53')]['id']},'include':[{'model':db[_0x092f('0x9a')],'as':_0x092f('0x9b'),'include':[{'model':db[_0x092f('0x6f')],'as':'Contacts','where':{'fax':_0x22f0e5},'limit':0x1,'order':[[_0x092f('0x9c'),_0x092f('0x9d')]]}]}]})[_0x092f('0x1f')](handleEntityNotFound(_0x229d6e,null))['then'](function(_0x175df6){_0x42215b=_0x175df6;if(_0x3ff364[_0x092f('0x56')][_0x092f('0x9e')]&&_0x3ff364['body'][_0x092f('0x9e')][_0x092f('0x46')]){for(var _0xb5cf9d=0x0;_0xb5cf9d<_0x3ff364['body'][_0x092f('0x9e')]['length'];_0xb5cf9d+=0x1){_0x3ff364[_0x092f('0x56')]['attachments'][_0xb5cf9d]={'filename':_0x3ff364['body']['attachments'][_0xb5cf9d][_0x092f('0x35')],'id':_0x3ff364[_0x092f('0x56')]['attachments'][_0xb5cf9d]['id'],'path':path['join'](config[_0x092f('0x9f')],_0x092f('0xa0'),_0x3ff364[_0x092f('0x56')][_0x092f('0x9e')][_0xb5cf9d][_0x092f('0xa1')])};}}return respondWithRpcPromise(_0x092f('0xa2'),_0x092f('0xa2'),{'FaxAccountId':_[_0x092f('0xa3')](_0x3ff364[_0x092f('0x53')]['id'])?undefined:_0x3ff364[_0x092f('0x53')]['id'],'path':_[_0x092f('0xa3')](_0x3ff364['body'][_0x092f('0x9e')][0x0][_0x092f('0x6')])?undefined:_0x3ff364['body'][_0x092f('0x9e')][0x0][_0x092f('0x6')],'fax':_['isNil'](_0x3ff364['body']['to'][0x0])?undefined:_0x3ff364[_0x092f('0x56')]['to'][0x0]},client9002);})['then'](function(){if(_0x42215b){if(_[_0x092f('0xa3')](_0x3ff364[_0x092f('0x56')]['from'])){_0x3ff364[_0x092f('0x56')]['from']=util[_0x092f('0x99')](_0x092f('0xa4'),_0x42215b[_0x092f('0x35')],_0x42215b[_0x092f('0xa5')]);}if(_0x42215b[_0x092f('0x9b')]){if(_0x42215b[_0x092f('0x9b')]['Contacts'][_0x092f('0x46')]){return _0x42215b['List']['Contacts'][0x0];}else{return db['CmContact'][_0x092f('0x55')](_[_0x092f('0x16')](_0x3ff364[_0x092f('0x56')],{'firstName':_0x3ff364[_0x092f('0x56')]['to'][0x0],'phone':_0x3ff364['body']['to'][0x0],'fax':_0x3ff364[_0x092f('0x56')]['to'][0x0],'ListId':_0x42215b['ListId']}));}}else{throw new Error(_0x092f('0xa6'));}}else{throw new Error(_0x092f('0xa7'));}})[_0x092f('0x1f')](function(_0x1aa25d){if(_0x1aa25d){return db[_0x092f('0x6c')][_0x092f('0x54')]({'where':{'ContactId':_0x1aa25d['id'],'closed':![],'FaxAccountId':_0x42215b['id']}})[_0x092f('0x1f')](function(_0x3fcc92){if(_0x3fcc92){return[_0x3fcc92,![]];}return db[_0x092f('0x6c')][_0x092f('0x55')]({'UserId':_0x3ff364[_0x092f('0x57')]['id'],'ContactId':_0x1aa25d['id'],'FaxAccountId':_0x42215b['id'],'fax':_0x3ff364[_0x092f('0x56')]['to'][0x0],'firstMsgDirection':_0x092f('0xa8'),'Messages':[_[_0x092f('0x4d')](_0x3ff364['body'],{'read':![],'body':_0x3ff364[_0x092f('0x56')][_0x092f('0x9e')][0x0][_0x092f('0xa9')],'FaxAccountId':_0x42215b['id'],'UserId':_0x3ff364['user']['id'],'ContactId':_0x1aa25d['id'],'AttachmentId':_0x3ff364[_0x092f('0x56')]['attachments'][0x0]['id']})]},{'include':[{'model':db[_0x092f('0x96')],'as':_0x092f('0xaa')}]})[_0x092f('0x1f')](function(_0x593e6a){return[_0x593e6a,!![]];});});}else{throw new Error(_0x092f('0xab'));}})[_0x092f('0xac')](function(_0x4c44b6,_0xbe6cf5){if(_0xbe6cf5){return _0x4c44b6;}return db['FaxMessage'][_0x092f('0x55')]({'direction':_0x092f('0xa8'),'read':![],'body':_0x3ff364['body']['attachments'][0x0][_0x092f('0xa9')],'FaxAccountId':_0x42215b['id'],'FaxInteractionId':_0x4c44b6['id'],'UserId':_0x3ff364[_0x092f('0x57')]['id'],'ContactId':_0x4c44b6['ContactId'],'AttachmentId':_0x3ff364[_0x092f('0x56')][_0x092f('0x9e')][0x0]['id']})['then'](function(_0x447b75){_0x4c44b6[_0x092f('0xad')]['Messages']=[];_0x4c44b6[_0x092f('0xad')][_0x092f('0xaa')][_0x092f('0x84')](_0x447b75[_0x092f('0xad')]);return _0x4c44b6;});})[_0x092f('0x1f')](function(_0x270749){respondWithRpcPromise('SendFax',_0x092f('0xae'),{'FaxAccountId':_[_0x092f('0xa3')](_0x3ff364[_0x092f('0x53')]['id'])?undefined:_0x3ff364['params']['id'],'path':_[_0x092f('0xa3')](_0x3ff364['body']['attachments'][0x0]['path'])?undefined:_0x3ff364[_0x092f('0x56')][_0x092f('0x9e')][0x0][_0x092f('0x6')],'fax':_[_0x092f('0xa3')](_0x3ff364[_0x092f('0x56')]['to'][0x0])?undefined:_0x3ff364[_0x092f('0x56')]['to'][0x0],'AttachmentId':_0x3ff364[_0x092f('0x56')][_0x092f('0x9e')][0x0]['id']},client9002)[_0x092f('0x1f')](function(_0x20b507){logger[_0x092f('0x27')](_0x092f('0xaf'),_0x20b507);})[_0x092f('0x29')](function(_0x1f2aa1){logger[_0x092f('0x27')]('SendFaxRpc,\x20%s',_0x1f2aa1);});return _0x270749;})[_0x092f('0x1f')](respondWithResult(_0x229d6e,null))['catch'](handleError(_0x229d6e,null));};exports[_0x092f('0xb0')]=function(_0x4f9668,_0x3e41cb,_0xb0b20c){return db[_0x092f('0x3b')][_0x092f('0x54')]({'where':{'id':_0x4f9668[_0x092f('0x53')]['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x3e41cb,null))[_0x092f('0x1f')](function(_0x1e2dd2){if(_0x1e2dd2){return _0x1e2dd2['addAgents'](_0x4f9668['body'][_0x092f('0x66')],_[_0x092f('0x6d')](_0x4f9668[_0x092f('0x56')],[_0x092f('0x66'),'id'])||{})[_0x092f('0xac')](function(_0x5e7e2d){for(var _0x6b9af7=0x0;_0x6b9af7<_0x4f9668[_0x092f('0x56')]['ids'][_0x092f('0x46')];_0x6b9af7+=0x1){socket[_0x092f('0xb1')]('userFaxAccount:save',{'UserId':_0x4f9668['body'][_0x092f('0x66')][_0x6b9af7],'FaxAccountId':_0x4f9668[_0x092f('0x53')]['id']});}return _0x5e7e2d;});}})[_0x092f('0x1f')](respondWithResult(_0x3e41cb,null))[_0x092f('0x29')](handleError(_0x3e41cb,null));};exports[_0x092f('0xb2')]=function(_0x4750d9,_0x19ef12,_0x106e97){return db[_0x092f('0x3b')][_0x092f('0x54')]({'where':{'id':_0x4750d9['params']['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x19ef12,null))[_0x092f('0x1f')](function(_0x4fdff1){if(_0x4fdff1){return _0x4fdff1[_0x092f('0xb2')](_0x4750d9[_0x092f('0x41')][_0x092f('0x66')])['then'](function(){if(_[_0x092f('0xb3')](_0x4750d9[_0x092f('0x41')][_0x092f('0x66')])){for(var _0x542cf1=0x0;_0x542cf1<_0x4750d9[_0x092f('0x41')][_0x092f('0x66')][_0x092f('0x46')];_0x542cf1+=0x1){socket[_0x092f('0xb1')]('userFaxAccount:remove',{'UserId':Number(_0x4750d9[_0x092f('0x41')][_0x092f('0x66')][_0x542cf1]),'FaxAccountId':Number(_0x4750d9['params']['id'])});}}else{socket[_0x092f('0xb1')](_0x092f('0xb4'),{'UserId':Number(_0x4750d9[_0x092f('0x41')][_0x092f('0x66')]),'FaxAccountId':Number(_0x4750d9[_0x092f('0x53')]['id'])});}});}})[_0x092f('0x1f')](respondWithStatusCode(_0x19ef12,null))['catch'](handleError(_0x19ef12,null));};exports[_0x092f('0xb5')]=function(_0x2da6ad,_0x1b9a10,_0x25c6ea){var _0x1ce11c={};var _0xe115c0={};var _0x39eaec;var _0x510781;return db[_0x092f('0x3b')][_0x092f('0x61')]({'where':{'id':_0x2da6ad['params']['id']}})[_0x092f('0x1f')](handleEntityNotFound(_0x1b9a10,null))[_0x092f('0x1f')](function(_0x54d741){if(_0x54d741){_0x39eaec=_0x54d741;_0xe115c0['model']=_[_0x092f('0x40')](db['User'][_0x092f('0x3c')]);_0xe115c0[_0x092f('0x41')]=_[_0x092f('0x40')](_0x2da6ad[_0x092f('0x41')]);_0xe115c0[_0x092f('0x42')]=_[_0x092f('0x43')](_0xe115c0[_0x092f('0x3f')],_0xe115c0[_0x092f('0x41')]);_0x1ce11c[_0x092f('0x44')]=_[_0x092f('0x43')](_0xe115c0[_0x092f('0x3f')],qs['fields'](_0x2da6ad[_0x092f('0x41')][_0x092f('0x45')]));_0x1ce11c[_0x092f('0x44')]=_0x1ce11c['attributes']['length']?_0x1ce11c['attributes']:_0xe115c0[_0x092f('0x3f')];_0x1ce11c[_0x092f('0x49')]=qs[_0x092f('0x62')](_0x2da6ad[_0x092f('0x41')][_0x092f('0x62')]);_0x1ce11c['where']=qs['filters'](_[_0x092f('0x4b')](_0x2da6ad['query'],_0xe115c0[_0x092f('0x42')]));if(_0x2da6ad[_0x092f('0x41')]['filter']){_0x1ce11c['where']=_[_0x092f('0x4d')](_0x1ce11c['where'],{'$or':_['map'](_0x1ce11c['attributes'],function(_0x595b94){var _0x435555={};_0x435555[_0x595b94]={'$like':'%'+_0x2da6ad['query'][_0x092f('0x4c')]+'%'};return _0x435555;})});}_0x1ce11c=_[_0x092f('0x4d')]({},_0x1ce11c,_0x2da6ad[_0x092f('0x4e')]);return _0x39eaec[_0x092f('0xb5')](_0x1ce11c);}})[_0x092f('0x1f')](function(_0xe39a20){if(_0xe39a20){_0x510781=_0xe39a20[_0x092f('0x46')];if(!_0x2da6ad[_0x092f('0x41')]['hasOwnProperty'](_0x092f('0x48'))){_0x1ce11c[_0x092f('0x2e')]=qs[_0x092f('0x2e')](_0x2da6ad[_0x092f('0x41')]['limit']);_0x1ce11c['offset']=qs[_0x092f('0x2d')](_0x2da6ad[_0x092f('0x41')][_0x092f('0x2d')]);}return _0x39eaec[_0x092f('0xb5')](_0x1ce11c);}})['then'](function(_0x597452){if(_0x597452){return _0x597452?{'count':_0x510781,'rows':_0x597452}:null;}})['then'](respondWithResult(_0x1b9a10,null))[_0x092f('0x29')](handleError(_0x1b9a10,null));};
\ No newline at end of file
+var _0x28d6=['sendStatus','name','send','Pause','map','FaxAccount','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','sort','where','filters','filter','merge','VIRTUAL','options','includeAll','params','find','create','user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','mandatoryDispositionPause','describe','addDisposition','FaxAccountId','Disposition','getDispositions','findOne','order','include','findAll','rows','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','hasOwnProperty','removeAnswers','FaxInteraction','addInteraction','getInteractions','pick','CmContact','Contact','User','Owner','fullname','internal','Tag','Tags','color','tag','sequelize','transaction','FaxApplication','bulkCreate','getApplications','from-voip-provider','exten','localstationid','app','system','description','priority','Answer','CDR(type)=inbound-fax','Set','ecm','faxdetect','maxrate','minrate','modem','t38timeout','push','Wait','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','addAccountApplications','VoiceExtension','createdAt','updatedAt','TrunkId','ListId','findById','getMessages','FaxMessage','$gte','split','format','List','Contacts','attachments','join','server/files/attachments','basename','CheckAfterSend','isNil','from','\x22%s\x22\x20<%s>','fax','Send\x20Fax\x20failed','out','filename','Messages','Contact\x20not\x20found','ContactId','dataValues','SendFax','SendFaxRpc,\x20%s','addAgents','emit','removeAgents','isArray','userFaxAccount:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','jayson/promise','client','http','request','then','info','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','FaxAccount,\x20%s,\x20%s','result','catch','end','json','count','offset','limit','status','set','update','destroy','get','FaxAccounts'];(function(_0x64aff8,_0x106082){var _0x5488a3=function(_0x36969c){while(--_0x36969c){_0x64aff8['push'](_0x64aff8['shift']());}};_0x5488a3(++_0x106082);}(_0x28d6,0x81));var _0x628d=function(_0x4a16aa,_0x46f661){_0x4a16aa=_0x4a16aa-0x0;var _0x4e9af4=_0x28d6[_0x4a16aa];return _0x4e9af4;};'use strict';var emlformat=require(_0x628d('0x0'));var rimraf=require(_0x628d('0x1'));var zipdir=require(_0x628d('0x2'));var jsonpatch=require(_0x628d('0x3'));var rp=require('request-promise');var moment=require(_0x628d('0x4'));var BPromise=require(_0x628d('0x5'));var Mustache=require(_0x628d('0x6'));var util=require(_0x628d('0x7'));var path=require(_0x628d('0x8'));var sox=require(_0x628d('0x9'));var csv=require('to-csv');var ejs=require(_0x628d('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x628d('0xb'));var jsforce=require(_0x628d('0xc'));var deskjs=require(_0x628d('0xd'));var toCsv=require(_0x628d('0xe'));var querystring=require(_0x628d('0xf'));var Papa=require('papaparse');var Redis=require(_0x628d('0x10'));var authService=require(_0x628d('0x11'));var qs=require(_0x628d('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x628d('0x13'));var logger=require(_0x628d('0x14'))(_0x628d('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x628d('0x16')]=_[_0x628d('0x17')](config['redis'],{'host':_0x628d('0x18'),'port':0x18eb});var socket=require(_0x628d('0x19'))(new Redis(config[_0x628d('0x16')]));require(_0x628d('0x1a'))['register'](socket);var jayson=require(_0x628d('0x1b'));var client=jayson[_0x628d('0x1c')][_0x628d('0x1d')]({'port':0x232c});var client9002=jayson[_0x628d('0x1c')][_0x628d('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x3680a8,_0x23b370,_0x5da258,_0x4c52a7){return new BPromise(function(_0xf8fb47,_0x4769a5){var _0xa4db01=_0x4c52a7||client;return _0xa4db01[_0x628d('0x1e')](_0x3680a8,_0x5da258)[_0x628d('0x1f')](function(_0x3c7ba5){logger[_0x628d('0x20')]('FaxAccount,\x20%s,\x20%s',_0x23b370,_0x628d('0x21'));logger[_0x628d('0x22')](_0x628d('0x23'),_0x23b370,_0x628d('0x21'),JSON[_0x628d('0x24')](_0x3c7ba5));if(_0x3c7ba5[_0x628d('0x25')]){if(_0x3c7ba5[_0x628d('0x25')][_0x628d('0x26')]===0x1f4){logger[_0x628d('0x25')]('FaxAccount,\x20%s,\x20%s',_0x23b370,_0x3c7ba5['error'][_0x628d('0x27')]);return _0x4769a5(_0x3c7ba5[_0x628d('0x25')][_0x628d('0x27')]);}logger[_0x628d('0x25')]('FaxAccount,\x20%s,\x20%s',_0x23b370,_0x3c7ba5[_0x628d('0x25')][_0x628d('0x27')]);return _0xf8fb47(_0x3c7ba5['error'][_0x628d('0x27')]);}else{logger[_0x628d('0x20')](_0x628d('0x28'),_0x23b370,_0x628d('0x21'));_0xf8fb47(_0x3c7ba5[_0x628d('0x29')][_0x628d('0x27')]);}})[_0x628d('0x2a')](function(_0x56b08e){logger[_0x628d('0x25')](_0x628d('0x28'),_0x23b370,_0x56b08e);_0x4769a5(_0x56b08e);});});}function respondWithStatusCode(_0xdb2989,_0x52ffa6){_0x52ffa6=_0x52ffa6||0xcc;return function(_0x4cd834){if(_0x4cd834){return _0xdb2989['sendStatus'](_0x52ffa6);}return _0xdb2989['status'](_0x52ffa6)[_0x628d('0x2b')]();};}function respondWithResult(_0x5a5d3e,_0x39ef76){_0x39ef76=_0x39ef76||0xc8;return function(_0x305db9){if(_0x305db9){return _0x5a5d3e['status'](_0x39ef76)[_0x628d('0x2c')](_0x305db9);}};}function respondWithFilteredResult(_0x25d9b1,_0x11d0d8){return function(_0xafb429){if(_0xafb429){var _0xf14cdc=_0xafb429[_0x628d('0x2d')],_0x595a68=_0x11d0d8[_0x628d('0x2e')],_0x246dfe=_0x11d0d8[_0x628d('0x2e')]+_0x11d0d8[_0x628d('0x2f')],_0x2aa41a;if(_0x246dfe>=_0xf14cdc){_0x246dfe=_0xf14cdc;_0x2aa41a=0xc8;}else{_0x2aa41a=0xce;}_0x25d9b1[_0x628d('0x30')](_0x2aa41a);return _0x25d9b1[_0x628d('0x31')]('Content-Range',_0x595a68+'-'+_0x246dfe+'/'+_0xf14cdc)[_0x628d('0x2c')](_0xafb429);}return null;};}function patchUpdates(_0x59e7da){return function(_0x99885){try{jsonpatch['apply'](_0x99885,_0x59e7da,!![]);}catch(_0x3bf63b){return BPromise['reject'](_0x3bf63b);}return _0x99885['save']();};}function saveUpdates(_0x48148d,_0x1aefa1){return function(_0x297773){if(_0x297773){return _0x297773[_0x628d('0x32')](_0x48148d)[_0x628d('0x1f')](function(_0x1cb7e9){return _0x1cb7e9;});}return null;};}function removeEntity(_0x3e1b9f,_0x208c4c){return function(_0x43d409){if(_0x43d409){return _0x43d409[_0x628d('0x33')]()['then'](function(){var _0x3909a0=_0x43d409[_0x628d('0x34')]({'plain':!![]});var _0x5442e6=_0x628d('0x35');return db['UserProfileResource'][_0x628d('0x33')]({'where':{'type':_0x5442e6,'resourceId':_0x3909a0['id']}})['then'](function(){return _0x43d409;});})[_0x628d('0x1f')](function(){_0x3e1b9f[_0x628d('0x30')](0xcc)[_0x628d('0x2b')]();});}};}function handleEntityNotFound(_0x36ef8d,_0x10aeaf){return function(_0x2cc151){if(!_0x2cc151){_0x36ef8d[_0x628d('0x36')](0x194);}return _0x2cc151;};}function handleError(_0x8a8e57,_0x4ed64d){_0x4ed64d=_0x4ed64d||0x1f4;return function(_0x59ed0b){logger[_0x628d('0x25')](_0x59ed0b['stack']);if(_0x59ed0b[_0x628d('0x37')]){delete _0x59ed0b[_0x628d('0x37')];}_0x8a8e57[_0x628d('0x30')](_0x4ed64d)[_0x628d('0x38')](_0x59ed0b);};}exports['index']=function(_0x1f445c,_0x548e18){var _0x3a26dd={'include':[{'model':db[_0x628d('0x39')],'as':'mandatoryDispositionPause'}]},_0x809c85={},_0x2363b9={'count':0x0,'rows':[]};var _0x26ade1=_[_0x628d('0x3a')](db[_0x628d('0x3b')][_0x628d('0x3c')],function(_0x3cb7a3){return{'name':_0x3cb7a3[_0x628d('0x3d')],'type':_0x3cb7a3[_0x628d('0x3e')][_0x628d('0x3f')]};});_0x809c85[_0x628d('0x40')]=_['map'](_0x26ade1,_0x628d('0x37'));_0x809c85[_0x628d('0x41')]=_[_0x628d('0x42')](_0x1f445c[_0x628d('0x41')]);_0x809c85['filters']=_[_0x628d('0x43')](_0x809c85[_0x628d('0x40')],_0x809c85[_0x628d('0x41')]);_0x3a26dd[_0x628d('0x44')]=_[_0x628d('0x43')](_0x809c85['model'],qs[_0x628d('0x45')](_0x1f445c[_0x628d('0x41')]['fields']));_0x3a26dd['attributes']=_0x3a26dd[_0x628d('0x44')][_0x628d('0x46')]?_0x3a26dd[_0x628d('0x44')]:_0x809c85[_0x628d('0x40')];if(!_0x1f445c[_0x628d('0x41')]['hasOwnProperty'](_0x628d('0x47'))){_0x3a26dd[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0x1f445c['query'][_0x628d('0x2f')]);_0x3a26dd['offset']=qs[_0x628d('0x2e')](_0x1f445c[_0x628d('0x41')]['offset']);}_0x3a26dd['order']=qs['sort'](_0x1f445c[_0x628d('0x41')][_0x628d('0x48')]);_0x3a26dd[_0x628d('0x49')]=qs[_0x628d('0x4a')](_['pick'](_0x1f445c[_0x628d('0x41')],_0x809c85[_0x628d('0x4a')]),_0x26ade1);if(_0x1f445c[_0x628d('0x41')][_0x628d('0x4b')]){_0x3a26dd[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x3a26dd['where'],{'$or':_[_0x628d('0x3a')](_0x26ade1,function(_0x4a8e65){if(_0x4a8e65['type']!==_0x628d('0x4d')){var _0x58637c={};_0x58637c[_0x4a8e65[_0x628d('0x37')]]={'$like':'%'+_0x1f445c[_0x628d('0x41')]['filter']+'%'};return _0x58637c;}})});}_0x3a26dd=_[_0x628d('0x4c')]({},_0x3a26dd,_0x1f445c[_0x628d('0x4e')]);var _0x5bb64a={'where':_0x3a26dd[_0x628d('0x49')]};return db[_0x628d('0x3b')]['count'](_0x5bb64a)[_0x628d('0x1f')](function(_0x53da93){_0x2363b9[_0x628d('0x2d')]=_0x53da93;if(_0x1f445c[_0x628d('0x41')][_0x628d('0x4f')]){_0x3a26dd['include']=[{'all':!![]}];}return db[_0x628d('0x3b')]['findAll'](_0x3a26dd);})['then'](function(_0x4444b0){_0x2363b9['rows']=_0x4444b0;return _0x2363b9;})[_0x628d('0x1f')](respondWithFilteredResult(_0x548e18,_0x3a26dd))[_0x628d('0x2a')](handleError(_0x548e18,null));};exports['show']=function(_0x3683db,_0x484da4){var _0x1d7431={'raw':![],'where':{'id':_0x3683db[_0x628d('0x50')]['id']},'include':[{'model':db[_0x628d('0x39')],'as':'mandatoryDispositionPause'}]},_0xefa316={};_0xefa316[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x3b')]['rawAttributes']);_0xefa316['query']=_[_0x628d('0x42')](_0x3683db['query']);_0xefa316[_0x628d('0x4a')]=_['intersection'](_0xefa316[_0x628d('0x40')],_0xefa316['query']);_0x1d7431[_0x628d('0x44')]=_['intersection'](_0xefa316[_0x628d('0x40')],qs['fields'](_0x3683db['query'][_0x628d('0x45')]));_0x1d7431[_0x628d('0x44')]=_0x1d7431[_0x628d('0x44')][_0x628d('0x46')]?_0x1d7431[_0x628d('0x44')]:_0xefa316[_0x628d('0x40')];if(_0x3683db[_0x628d('0x41')]['includeAll']){_0x1d7431['include']=[{'all':!![]}];}_0x1d7431=_[_0x628d('0x4c')]({},_0x1d7431,_0x3683db[_0x628d('0x4e')]);return db['FaxAccount'][_0x628d('0x51')](_0x1d7431)[_0x628d('0x1f')](handleEntityNotFound(_0x484da4,null))[_0x628d('0x1f')](respondWithResult(_0x484da4,null))[_0x628d('0x2a')](handleError(_0x484da4,null));};exports[_0x628d('0x52')]=function(_0x443fe2,_0x19ba95){return db['FaxAccount'][_0x628d('0x52')](_0x443fe2['body'],{})[_0x628d('0x1f')](function(_0x49382e){var _0x153d42=_0x443fe2[_0x628d('0x53')][_0x628d('0x34')]({'plain':!![]});if(!_0x153d42)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x153d42[_0x628d('0x54')]===_0x628d('0x53')){var _0x698124=_0x49382e['get']({'plain':!![]});var _0x4a47f7=_0x628d('0x35');return db[_0x628d('0x55')][_0x628d('0x51')]({'where':{'name':_0x4a47f7,'userProfileId':_0x153d42[_0x628d('0x56')]},'raw':!![]})['then'](function(_0x238918){if(_0x238918&&_0x238918['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x698124[_0x628d('0x37')],'resourceId':_0x698124['id'],'type':_0x238918[_0x628d('0x37')],'sectionId':_0x238918['id']},{})[_0x628d('0x1f')](function(){return _0x49382e;});}else{return _0x49382e;}})[_0x628d('0x2a')](function(_0x2680cf){logger[_0x628d('0x25')](_0x628d('0x57'),_0x2680cf);throw _0x2680cf;});}return _0x49382e;})[_0x628d('0x1f')](respondWithResult(_0x19ba95,0xc9))[_0x628d('0x2a')](handleError(_0x19ba95,null));};exports[_0x628d('0x32')]=function(_0x1a79a1,_0x3fca63){if(_0x1a79a1[_0x628d('0x58')]['id']){delete _0x1a79a1[_0x628d('0x58')]['id'];}return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x1a79a1['params']['id']},'include':[{'model':db[_0x628d('0x39')],'as':_0x628d('0x59')}]})[_0x628d('0x1f')](handleEntityNotFound(_0x3fca63,null))[_0x628d('0x1f')](saveUpdates(_0x1a79a1['body'],null))[_0x628d('0x1f')](respondWithResult(_0x3fca63,null))['catch'](handleError(_0x3fca63,null));};exports['destroy']=function(_0x3e6ec9,_0x4ed757){return db[_0x628d('0x3b')][_0x628d('0x51')]({'where':{'id':_0x3e6ec9['params']['id']}})['then'](handleEntityNotFound(_0x4ed757,null))[_0x628d('0x1f')](removeEntity(_0x4ed757,null))['catch'](handleError(_0x4ed757,null));};exports[_0x628d('0x5a')]=function(_0x19f446,_0x3088f6){return db[_0x628d('0x3b')][_0x628d('0x5a')]()['then'](respondWithResult(_0x3088f6,null))['catch'](handleError(_0x3088f6,null));};exports[_0x628d('0x5b')]=function(_0x2293bf,_0x1fa564,_0x1f0fdb){if(_0x2293bf['body']['id']){delete _0x2293bf['body']['id'];}return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x2293bf[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x1fa564,null))['then'](function(_0x3e2d85){if(_0x3e2d85){_0x2293bf['body'][_0x628d('0x5c')]=_0x3e2d85['id'];return db[_0x628d('0x5d')][_0x628d('0x52')](_0x2293bf[_0x628d('0x58')]);}})['then'](respondWithResult(_0x1fa564,null))['catch'](handleError(_0x1fa564,null));};exports[_0x628d('0x5e')]=function(_0x4ba9de,_0x4647bc,_0x5a18a8){var _0x59e871={'raw':![],'where':{}};var _0x4c8345={};var _0x56398e={'count':0x0,'rows':[]};return db[_0x628d('0x3b')][_0x628d('0x5f')]({'where':{'id':_0x4ba9de['params']['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x4647bc,null))[_0x628d('0x1f')](function(_0x2d34e7){if(_0x2d34e7){_0x4c8345[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x5d')][_0x628d('0x3c')]);_0x4c8345['query']=_[_0x628d('0x42')](_0x4ba9de['query']);_0x4c8345['filters']=_[_0x628d('0x43')](_0x4c8345[_0x628d('0x40')],_0x4c8345[_0x628d('0x41')]);_0x59e871[_0x628d('0x44')]=_[_0x628d('0x43')](_0x4c8345['model'],qs[_0x628d('0x45')](_0x4ba9de[_0x628d('0x41')][_0x628d('0x45')]));_0x59e871['attributes']=_0x59e871[_0x628d('0x44')][_0x628d('0x46')]?_0x59e871[_0x628d('0x44')]:_0x4c8345['model'];if(!_0x4ba9de[_0x628d('0x41')]['hasOwnProperty'](_0x628d('0x47'))){_0x59e871[_0x628d('0x2f')]=qs['limit'](_0x4ba9de[_0x628d('0x41')][_0x628d('0x2f')]);_0x59e871[_0x628d('0x2e')]=qs[_0x628d('0x2e')](_0x4ba9de[_0x628d('0x41')][_0x628d('0x2e')]);}_0x59e871[_0x628d('0x60')]=qs[_0x628d('0x48')](_0x4ba9de['query'][_0x628d('0x48')]);_0x59e871[_0x628d('0x49')]=qs['filters'](_['pick'](_0x4ba9de[_0x628d('0x41')],_0x4c8345[_0x628d('0x4a')]));_0x59e871[_0x628d('0x49')][_0x628d('0x5c')]=_0x2d34e7['id'];if(_0x4ba9de[_0x628d('0x41')]['filter']){_0x59e871[_0x628d('0x49')]=_['merge'](_0x59e871[_0x628d('0x49')],{'$or':_[_0x628d('0x3a')](_0x59e871[_0x628d('0x44')],function(_0x39a724){var _0x20569c={};_0x20569c[_0x39a724]={'$like':'%'+_0x4ba9de[_0x628d('0x41')]['filter']+'%'};return _0x20569c;})});}_0x59e871=_[_0x628d('0x4c')]({},_0x59e871,_0x4ba9de[_0x628d('0x4e')]);return db[_0x628d('0x5d')][_0x628d('0x2d')]({'where':_0x59e871['where']})['then'](function(_0x44c461){_0x56398e[_0x628d('0x2d')]=_0x44c461;if(_0x4ba9de['query']['includeAll']){_0x59e871[_0x628d('0x61')]=[{'all':!![]}];}return db[_0x628d('0x5d')][_0x628d('0x62')](_0x59e871);})['then'](function(_0x151678){_0x56398e[_0x628d('0x63')]=_0x151678;return _0x56398e;});}})['then'](respondWithFilteredResult(_0x4647bc,_0x59e871))[_0x628d('0x2a')](handleError(_0x4647bc,null));};exports[_0x628d('0x64')]=function(_0x5ad265,_0x4c74a1,_0x31ba24){return db[_0x628d('0x3b')][_0x628d('0x51')]({'where':{'id':_0x5ad265[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x4c74a1,null))[_0x628d('0x1f')](function(_0x2f5db2){if(_0x2f5db2){return _0x2f5db2['removeDispositions'](_0x5ad265[_0x628d('0x41')][_0x628d('0x65')]);}})[_0x628d('0x1f')](respondWithStatusCode(_0x4c74a1,null))[_0x628d('0x2a')](handleError(_0x4c74a1,null));};exports[_0x628d('0x66')]=function(_0x3cc3b1,_0x15474c,_0x4702e0){if(_0x3cc3b1['body']['id']){delete _0x3cc3b1[_0x628d('0x58')]['id'];}return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x3cc3b1[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x15474c,null))[_0x628d('0x1f')](function(_0x20afd7){if(_0x20afd7){_0x3cc3b1[_0x628d('0x58')]['FaxAccountId']=_0x20afd7['id'];return db[_0x628d('0x67')][_0x628d('0x52')](_0x3cc3b1[_0x628d('0x58')]);}})['then'](respondWithResult(_0x15474c,null))['catch'](handleError(_0x15474c,null));};exports[_0x628d('0x68')]=function(_0x3105c2,_0x41b18a,_0x1382fb){var _0xae651c={'raw':![],'where':{}};var _0x39fc7e={};var _0x4f6150={'count':0x0,'rows':[]};return db[_0x628d('0x3b')]['findOne']({'where':{'id':_0x3105c2['params']['id']}})['then'](handleEntityNotFound(_0x41b18a,null))['then'](function(_0x11673a){if(_0x11673a){_0x39fc7e[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x67')]['rawAttributes']);_0x39fc7e[_0x628d('0x41')]=_[_0x628d('0x42')](_0x3105c2[_0x628d('0x41')]);_0x39fc7e['filters']=_[_0x628d('0x43')](_0x39fc7e[_0x628d('0x40')],_0x39fc7e[_0x628d('0x41')]);_0xae651c[_0x628d('0x44')]=_[_0x628d('0x43')](_0x39fc7e['model'],qs[_0x628d('0x45')](_0x3105c2['query'][_0x628d('0x45')]));_0xae651c[_0x628d('0x44')]=_0xae651c[_0x628d('0x44')][_0x628d('0x46')]?_0xae651c[_0x628d('0x44')]:_0x39fc7e[_0x628d('0x40')];if(!_0x3105c2[_0x628d('0x41')][_0x628d('0x69')](_0x628d('0x47'))){_0xae651c[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0x3105c2[_0x628d('0x41')][_0x628d('0x2f')]);_0xae651c[_0x628d('0x2e')]=qs['offset'](_0x3105c2[_0x628d('0x41')][_0x628d('0x2e')]);}_0xae651c[_0x628d('0x60')]=qs['sort'](_0x3105c2['query'][_0x628d('0x48')]);_0xae651c[_0x628d('0x49')]=qs['filters'](_['pick'](_0x3105c2[_0x628d('0x41')],_0x39fc7e[_0x628d('0x4a')]));_0xae651c['where'][_0x628d('0x5c')]=_0x11673a['id'];if(_0x3105c2[_0x628d('0x41')]['filter']){_0xae651c[_0x628d('0x49')]=_[_0x628d('0x4c')](_0xae651c['where'],{'$or':_[_0x628d('0x3a')](_0xae651c[_0x628d('0x44')],function(_0xe67981){var _0x501275={};_0x501275[_0xe67981]={'$like':'%'+_0x3105c2['query']['filter']+'%'};return _0x501275;})});}_0xae651c=_[_0x628d('0x4c')]({},_0xae651c,_0x3105c2[_0x628d('0x4e')]);return db['CannedAnswer'][_0x628d('0x2d')]({'where':_0xae651c[_0x628d('0x49')]})['then'](function(_0xaeac8d){_0x4f6150[_0x628d('0x2d')]=_0xaeac8d;if(_0x3105c2[_0x628d('0x41')][_0x628d('0x4f')]){_0xae651c[_0x628d('0x61')]=[{'all':!![]}];}return db['CannedAnswer'][_0x628d('0x62')](_0xae651c);})[_0x628d('0x1f')](function(_0x55384e){_0x4f6150[_0x628d('0x63')]=_0x55384e;return _0x4f6150;});}})[_0x628d('0x1f')](respondWithFilteredResult(_0x41b18a,_0xae651c))['catch'](handleError(_0x41b18a,null));};exports[_0x628d('0x6a')]=function(_0x4ddeb1,_0x225c59,_0x4fb16d){return db[_0x628d('0x3b')][_0x628d('0x51')]({'where':{'id':_0x4ddeb1[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x225c59,null))[_0x628d('0x1f')](function(_0x5c81e0){if(_0x5c81e0){return _0x5c81e0[_0x628d('0x6a')](_0x4ddeb1[_0x628d('0x41')][_0x628d('0x65')]);}})[_0x628d('0x1f')](respondWithStatusCode(_0x225c59,null))[_0x628d('0x2a')](handleError(_0x225c59,null));};exports['addInteraction']=function(_0x67c2d5,_0x11339f,_0x2f57ac){return db[_0x628d('0x6b')][_0x628d('0x51')]({'where':{'id':_0x67c2d5[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x11339f,null))['then'](function(_0x1c9124){if(_0x1c9124){return _0x1c9124[_0x628d('0x6c')](_0x67c2d5['body']['ids'],_['omit'](_0x67c2d5[_0x628d('0x58')],[_0x628d('0x65'),'id'])||{});}})[_0x628d('0x1f')](respondWithResult(_0x11339f,null))[_0x628d('0x2a')](handleError(_0x11339f,null));};exports[_0x628d('0x6d')]=function(_0x12e593,_0x41631a,_0x48f8c8){var _0x206597={'raw':![],'where':{}};var _0x55783c={};var _0x11e3f5={'count':0x0,'rows':[]};return db[_0x628d('0x3b')][_0x628d('0x5f')]({'where':{'id':_0x12e593[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x41631a,null))[_0x628d('0x1f')](function(_0x32a2ae){if(_0x32a2ae){_0x55783c[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x6b')]['rawAttributes']);_0x55783c[_0x628d('0x41')]=_[_0x628d('0x42')](_0x12e593[_0x628d('0x41')]);_0x55783c['filters']=_['intersection'](_0x55783c[_0x628d('0x40')],_0x55783c['query']);_0x206597[_0x628d('0x44')]=_[_0x628d('0x43')](_0x55783c['model'],qs[_0x628d('0x45')](_0x12e593[_0x628d('0x41')][_0x628d('0x45')]));_0x206597[_0x628d('0x44')]=_0x206597[_0x628d('0x44')][_0x628d('0x46')]?_0x206597[_0x628d('0x44')]:_0x55783c[_0x628d('0x40')];if(!_0x12e593[_0x628d('0x41')][_0x628d('0x69')](_0x628d('0x47'))){_0x206597['limit']=qs[_0x628d('0x2f')](_0x12e593[_0x628d('0x41')][_0x628d('0x2f')]);_0x206597[_0x628d('0x2e')]=qs[_0x628d('0x2e')](_0x12e593[_0x628d('0x41')][_0x628d('0x2e')]);}_0x206597[_0x628d('0x60')]=qs[_0x628d('0x48')](_0x12e593[_0x628d('0x41')][_0x628d('0x48')]);_0x206597['where']=qs[_0x628d('0x4a')](_[_0x628d('0x6e')](_0x12e593[_0x628d('0x41')],_0x55783c[_0x628d('0x4a')]));_0x206597['where'][_0x628d('0x5c')]=_0x32a2ae['id'];if(_0x12e593[_0x628d('0x41')]['filter']){_0x206597[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x206597['where'],{'$or':_[_0x628d('0x3a')](_0x206597[_0x628d('0x44')],function(_0x2c90f8){var _0xbe13b8={};_0xbe13b8[_0x2c90f8]={'$like':'%'+_0x12e593['query']['filter']+'%'};return _0xbe13b8;})});}_0x206597=_[_0x628d('0x4c')]({},_0x206597,_0x12e593[_0x628d('0x4e')]);return db[_0x628d('0x6b')][_0x628d('0x2d')]({'where':_0x206597[_0x628d('0x49')]})[_0x628d('0x1f')](function(_0x11f162){_0x11e3f5['count']=_0x11f162;if(_0x12e593['query'][_0x628d('0x4f')]){_0x206597['include']=[{'model':db[_0x628d('0x6f')],'as':_0x628d('0x70'),'required':![]},{'model':db[_0x628d('0x71')],'as':_0x628d('0x72'),'attributes':[_0x628d('0x37'),_0x628d('0x73'),_0x628d('0x74')],'required':![]},{'model':db[_0x628d('0x75')],'as':_0x628d('0x76'),'attributes':['id',_0x628d('0x37'),_0x628d('0x77')],'where':_0x12e593[_0x628d('0x41')][_0x628d('0x78')]?{'id':_0x12e593['query'][_0x628d('0x78')]}:undefined,'required':_0x12e593[_0x628d('0x41')]['tag']?!![]:![]}];}return db[_0x628d('0x6b')]['findAll'](_0x206597);})['then'](function(_0x52ade0){_0x11e3f5[_0x628d('0x63')]=_0x52ade0;return _0x11e3f5;});}})[_0x628d('0x1f')](respondWithFilteredResult(_0x41631a,_0x206597))[_0x628d('0x2a')](handleError(_0x41631a,null));};exports['addApplications']=function(_0x3ca76a,_0xf308c0,_0x94a838){return db[_0x628d('0x3b')][_0x628d('0x5f')]({'where':{'id':_0x3ca76a[_0x628d('0x50')]['id']}})['then'](handleEntityNotFound(_0xf308c0,null))['then'](function(_0x347c3c){if(_0x347c3c){return db[_0x628d('0x79')][_0x628d('0x7a')](function(_0x2d064b){return db[_0x628d('0x7b')][_0x628d('0x33')]({'where':{'FaxAccountId':_0x3ca76a[_0x628d('0x50')]['id']},'transaction':_0x2d064b})[_0x628d('0x1f')](function(_0x39db16){var _0x43c999=_['map'](_0x3ca76a[_0x628d('0x58')],function(_0x304574){_0x304574['FaxAccountId']=_0x3ca76a['params']['id'];return _0x304574;});return db[_0x628d('0x7b')][_0x628d('0x7c')](_0x43c999,{'transaction':_0x2d064b});});})[_0x628d('0x1f')](function(){return db[_0x628d('0x7b')]['findAndCountAll']({'where':{'FaxAccountId':_0x3ca76a[_0x628d('0x50')]['id']},'order':'priority'});});}})[_0x628d('0x1f')](respondWithResult(_0xf308c0,null))['catch'](handleError(_0xf308c0,null));};exports[_0x628d('0x7d')]=function(_0x27e59c,_0x1bac4a,_0x553073){var _0x50fd72={};var _0x227a6b={};var _0x1e1ce7;var _0x82ff66;return db['FaxAccount'][_0x628d('0x5f')]({'where':{'id':_0x27e59c['params']['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x1bac4a,null))[_0x628d('0x1f')](function(_0x478f46){if(_0x478f46){_0x1e1ce7=_0x478f46;_0x227a6b[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x7b')][_0x628d('0x3c')]);_0x227a6b[_0x628d('0x41')]=_[_0x628d('0x42')](_0x27e59c[_0x628d('0x41')]);_0x227a6b[_0x628d('0x4a')]=_[_0x628d('0x43')](_0x227a6b[_0x628d('0x40')],_0x227a6b[_0x628d('0x41')]);_0x50fd72[_0x628d('0x44')]=_[_0x628d('0x43')](_0x227a6b[_0x628d('0x40')],qs[_0x628d('0x45')](_0x27e59c[_0x628d('0x41')]['fields']));_0x50fd72[_0x628d('0x44')]=_0x50fd72[_0x628d('0x44')][_0x628d('0x46')]?_0x50fd72['attributes']:_0x227a6b[_0x628d('0x40')];_0x50fd72[_0x628d('0x60')]=qs[_0x628d('0x48')](_0x27e59c[_0x628d('0x41')][_0x628d('0x48')]);_0x50fd72['where']=qs[_0x628d('0x4a')](_[_0x628d('0x6e')](_0x27e59c['query'],_0x227a6b[_0x628d('0x4a')]));if(_0x27e59c[_0x628d('0x41')][_0x628d('0x4b')]){_0x50fd72[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x50fd72[_0x628d('0x49')],{'$or':_['map'](_0x50fd72[_0x628d('0x44')],function(_0x296113){var _0x127bb8={};_0x127bb8[_0x296113]={'$like':'%'+_0x27e59c['query'][_0x628d('0x4b')]+'%'};return _0x127bb8;})});}_0x50fd72=_['merge']({},_0x50fd72,_0x27e59c[_0x628d('0x4e')]);return _0x1e1ce7['getApplications'](_0x50fd72);}})[_0x628d('0x1f')](function(_0xd0e698){if(_0xd0e698){_0x82ff66=_0xd0e698['length'];if(!_0x27e59c['query']['hasOwnProperty'](_0x628d('0x47'))){_0x50fd72[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0x27e59c[_0x628d('0x41')][_0x628d('0x2f')]);_0x50fd72[_0x628d('0x2e')]=qs[_0x628d('0x2e')](_0x27e59c[_0x628d('0x41')]['offset']);}return _0x1e1ce7[_0x628d('0x7d')](_0x50fd72);}})[_0x628d('0x1f')](function(_0x574d6e){if(_0x574d6e){return _0x574d6e?{'count':_0x82ff66,'rows':_0x574d6e}:null;}})[_0x628d('0x1f')](respondWithResult(_0x1bac4a,null))[_0x628d('0x2a')](handleError(_0x1bac4a,null));};function Extension(_0x979516,_0x1d85c9,_0x3c9ce9,_0x4e8ad1){this['context']=_0x628d('0x7e');this[_0x628d('0x7f')]=_0x979516[_0x628d('0x80')];this[_0x628d('0x81')]=_0x4e8ad1;this[_0x628d('0x3e')]=_0x628d('0x82');this[_0x628d('0x83')]='Fax\x20Extension';this['FaxAccountId']=_0x979516['id'];this[_0x628d('0x84')]=_0x1d85c9;this['appdata']=_0x3c9ce9;}function createExtensionsReciveFax(_0x1c4ee8){var _0x4d5519=0x1;var _0x20d9bb=[];_0x20d9bb['push'](new Extension(_0x1c4ee8,_0x4d5519,'',_0x628d('0x85')));_0x4d5519+=0x1;_0x20d9bb['push'](new Extension(_0x1c4ee8,_0x4d5519,_0x628d('0x86'),_0x628d('0x87')));_0x4d5519+=0x1;for(var _0x32c0e0 in _0x1c4ee8){if(_0x1c4ee8[_0x628d('0x69')](_0x32c0e0)&&(_0x32c0e0===_0x628d('0x88')||_0x32c0e0===_0x628d('0x80')||_0x32c0e0==='gateway'||_0x32c0e0===_0x628d('0x89')||_0x32c0e0==='headerinfo'||_0x32c0e0===_0x628d('0x8a')||_0x32c0e0===_0x628d('0x8b')||_0x32c0e0===_0x628d('0x8c')||_0x32c0e0===_0x628d('0x8d'))){_0x20d9bb[_0x628d('0x8e')](new Extension(_0x1c4ee8,_0x4d5519,'FAXOPT('+_0x32c0e0+')='+_0x1c4ee8[_0x32c0e0],_0x628d('0x87')));_0x4d5519+=0x1;}}_0x20d9bb[_0x628d('0x8e')](new Extension(_0x1c4ee8,_0x4d5519,'6',_0x628d('0x8f')));_0x4d5519+=0x1;_0x20d9bb[_0x628d('0x8e')](new Extension(_0x1c4ee8,_0x4d5519,_0x628d('0x90'),'ReceiveFax'));_0x4d5519=0x0;return _0x20d9bb;}exports[_0x628d('0x91')]=function(_0x4a7f40,_0x5bbdf1,_0x49fde2){var _0x403e8a;return db['sequelize'][_0x628d('0x7a')](function(_0x5df29b){return db[_0x628d('0x3b')][_0x628d('0x52')](_0x4a7f40['body'],{'transaction':_0x5df29b})[_0x628d('0x1f')](function(_0x9f4119){_0x403e8a=_0x9f4119[_0x628d('0x34')]({'plain':!![]});return db[_0x628d('0x92')][_0x628d('0x7c')](createExtensionsReciveFax(_0x403e8a),{'transaction':_0x5df29b});});})[_0x628d('0x1f')](function(){return _0x403e8a;})[_0x628d('0x1f')](respondWithResult(_0x5bbdf1,null))[_0x628d('0x2a')](handleError(_0x5bbdf1,null));};exports['updateAccountApplications']=function(_0x350033,_0x311ed6,_0x84e68c){var _0x155895;return db[_0x628d('0x79')][_0x628d('0x7a')](function(_0x4a5c6d){return db[_0x628d('0x3b')][_0x628d('0x32')](_0x350033[_0x628d('0x58')],{'where':{'id':_0x350033[_0x628d('0x58')]['id']},'transaction':_0x4a5c6d})[_0x628d('0x1f')](function(_0x11e6b5){return db[_0x628d('0x92')][_0x628d('0x33')]({'where':{'FaxAccountId':_0x350033[_0x628d('0x58')]['id']},'transaction':_0x4a5c6d})[_0x628d('0x1f')](function(_0x146ca9){return db[_0x628d('0x92')][_0x628d('0x7c')](createExtensionsReciveFax(_['omit'](_0x350033[_0x628d('0x58')],['tech','key',_0x628d('0x93'),_0x628d('0x94'),_0x628d('0x95'),_0x628d('0x96')])),{'transaction':_0x4a5c6d});});});})[_0x628d('0x1f')](function(){return db[_0x628d('0x3b')][_0x628d('0x97')](_0x350033[_0x628d('0x58')]['id']);})[_0x628d('0x1f')](respondWithResult(_0x311ed6,null))['catch'](handleError(_0x311ed6,null));};exports[_0x628d('0x98')]=function(_0x293412,_0x3ed86b,_0x1a0047){var _0x369a6c={'raw':!![],'where':{}};var _0x5e1c63={};var _0x497d84={'count':0x0,'rows':[]};return db['FaxAccount'][_0x628d('0x5f')]({'where':{'id':_0x293412['params']['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x3ed86b,null))['then'](function(_0x1ee4ce){if(_0x1ee4ce){_0x5e1c63[_0x628d('0x40')]=_[_0x628d('0x42')](db[_0x628d('0x99')][_0x628d('0x3c')]);_0x5e1c63[_0x628d('0x41')]=_[_0x628d('0x42')](_0x293412[_0x628d('0x41')]);_0x5e1c63[_0x628d('0x4a')]=_[_0x628d('0x43')](_0x5e1c63['model'],_0x5e1c63[_0x628d('0x41')]);_0x369a6c[_0x628d('0x44')]=_['intersection'](_0x5e1c63[_0x628d('0x40')],qs[_0x628d('0x45')](_0x293412['query'][_0x628d('0x45')]));_0x369a6c[_0x628d('0x44')]=_0x369a6c['attributes'][_0x628d('0x46')]?_0x369a6c[_0x628d('0x44')]:_0x5e1c63['model'];if(!_0x293412[_0x628d('0x41')][_0x628d('0x69')]('nolimit')){_0x369a6c[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0x293412[_0x628d('0x41')][_0x628d('0x2f')]);_0x369a6c[_0x628d('0x2e')]=qs['offset'](_0x293412['query'][_0x628d('0x2e')]);}_0x369a6c['order']=qs[_0x628d('0x48')](_0x293412['query'][_0x628d('0x48')]);_0x369a6c[_0x628d('0x49')]=qs[_0x628d('0x4a')](_[_0x628d('0x6e')](_0x293412[_0x628d('0x41')],_0x5e1c63['filters']));_0x369a6c['where'][_0x628d('0x5c')]=_0x1ee4ce['id'];if(_0x293412[_0x628d('0x41')]['filter']){_0x369a6c[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x369a6c[_0x628d('0x49')],{'$or':_['map'](_0x369a6c[_0x628d('0x44')],function(_0x1bca26){var _0x54c40f={};_0x54c40f[_0x1bca26]={'$like':'%'+_0x293412[_0x628d('0x41')][_0x628d('0x4b')]+'%'};return _0x54c40f;})});}if(_0x293412['query'][_0x628d('0x9a')]){var _0x245f22=_0x293412[_0x628d('0x41')][_0x628d('0x9a')][_0x628d('0x9b')](',');var _0x49dc60={};_0x49dc60[_0x245f22[0x0]]={'$gte':moment(_0x245f22[0x1])[_0x628d('0x9c')]('YYYY-MM-DD\x20HH:mm:ss')};_0x369a6c[_0x628d('0x49')]=_['merge'](_0x369a6c[_0x628d('0x49')],_0x49dc60);}_0x369a6c=_[_0x628d('0x4c')]({},_0x369a6c,_0x293412['options']);return db['FaxMessage'][_0x628d('0x2d')]({'where':_0x369a6c[_0x628d('0x49')]})[_0x628d('0x1f')](function(_0x56380){_0x497d84[_0x628d('0x2d')]=_0x56380;if(_0x293412[_0x628d('0x41')][_0x628d('0x4f')]){_0x369a6c['include']=[{'all':!![]}];}return db[_0x628d('0x99')][_0x628d('0x62')](_0x369a6c);})[_0x628d('0x1f')](function(_0x1c0316){_0x497d84[_0x628d('0x63')]=_0x1c0316;return _0x497d84;});}})['then'](respondWithFilteredResult(_0x3ed86b,_0x369a6c))[_0x628d('0x2a')](handleError(_0x3ed86b,null));};exports[_0x628d('0x38')]=function(_0x318590,_0x454f1a,_0x354230){var _0x116504,_0x1e00d4={},_0x295977;if(_0x318590[_0x628d('0x58')]['to']){_0x295977=_0x318590[_0x628d('0x58')]['to'][0x0];}return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x318590[_0x628d('0x50')]['id']},'include':[{'model':db['CmList'],'as':_0x628d('0x9d'),'include':[{'model':db[_0x628d('0x6f')],'as':_0x628d('0x9e'),'where':{'fax':_0x295977},'limit':0x1,'order':[['updatedAt','DESC']]}]}]})[_0x628d('0x1f')](handleEntityNotFound(_0x454f1a,null))['then'](function(_0x27b185){_0x116504=_0x27b185;if(_0x318590['body'][_0x628d('0x9f')]&&_0x318590[_0x628d('0x58')]['attachments']['length']){for(var _0x1c370d=0x0;_0x1c370d<_0x318590[_0x628d('0x58')]['attachments'][_0x628d('0x46')];_0x1c370d+=0x1){_0x318590['body']['attachments'][_0x1c370d]={'filename':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][_0x1c370d][_0x628d('0x37')],'id':_0x318590['body'][_0x628d('0x9f')][_0x1c370d]['id'],'path':path[_0x628d('0xa0')](config['root'],_0x628d('0xa1'),_0x318590[_0x628d('0x58')][_0x628d('0x9f')][_0x1c370d][_0x628d('0xa2')])};}}return respondWithRpcPromise(_0x628d('0xa3'),_0x628d('0xa3'),{'FaxAccountId':_[_0x628d('0xa4')](_0x318590[_0x628d('0x50')]['id'])?undefined:_0x318590[_0x628d('0x50')]['id'],'path':_[_0x628d('0xa4')](_0x318590[_0x628d('0x58')]['attachments'][0x0][_0x628d('0x8')])?undefined:_0x318590['body'][_0x628d('0x9f')][0x0][_0x628d('0x8')],'fax':_['isNil'](_0x318590['body']['to'][0x0])?undefined:_0x318590['body']['to'][0x0]},client9002);})[_0x628d('0x1f')](function(){if(_0x116504){if(_[_0x628d('0xa4')](_0x318590['body'][_0x628d('0xa5')])){_0x318590[_0x628d('0x58')][_0x628d('0xa5')]=util[_0x628d('0x9c')](_0x628d('0xa6'),_0x116504[_0x628d('0x37')],_0x116504[_0x628d('0xa7')]);}if(_0x116504[_0x628d('0x9d')]){if(_0x116504[_0x628d('0x9d')][_0x628d('0x9e')]['length']){return _0x116504[_0x628d('0x9d')]['Contacts'][0x0];}else{return db['CmContact']['create'](_[_0x628d('0x17')](_0x318590[_0x628d('0x58')],{'firstName':_0x318590['body']['to'][0x0],'phone':_0x318590[_0x628d('0x58')]['to'][0x0],'fax':_0x318590[_0x628d('0x58')]['to'][0x0],'ListId':_0x116504[_0x628d('0x96')]}));}}else{throw new Error('List\x20not\x20found');}}else{throw new Error(_0x628d('0xa8'));}})[_0x628d('0x1f')](function(_0x42edeb){if(_0x42edeb){return db[_0x628d('0x6b')]['find']({'where':{'ContactId':_0x42edeb['id'],'closed':![],'FaxAccountId':_0x116504['id']}})[_0x628d('0x1f')](function(_0x5d7514){if(_0x5d7514){return[_0x5d7514,![]];}return db['FaxInteraction'][_0x628d('0x52')]({'UserId':_0x318590[_0x628d('0x53')]['id'],'ContactId':_0x42edeb['id'],'FaxAccountId':_0x116504['id'],'fax':_0x318590['body']['to'][0x0],'firstMsgDirection':_0x628d('0xa9'),'Messages':[_[_0x628d('0x4c')](_0x318590['body'],{'read':![],'body':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0][_0x628d('0xaa')],'FaxAccountId':_0x116504['id'],'UserId':_0x318590[_0x628d('0x53')]['id'],'ContactId':_0x42edeb['id'],'AttachmentId':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0]['id']})]},{'include':[{'model':db[_0x628d('0x99')],'as':_0x628d('0xab')}]})[_0x628d('0x1f')](function(_0x541acb){return[_0x541acb,!![]];});});}else{throw new Error(_0x628d('0xac'));}})['spread'](function(_0x43d9b3,_0x13b125){if(_0x13b125){return _0x43d9b3;}return db[_0x628d('0x99')][_0x628d('0x52')]({'direction':'out','read':![],'body':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0]['filename'],'FaxAccountId':_0x116504['id'],'FaxInteractionId':_0x43d9b3['id'],'UserId':_0x318590[_0x628d('0x53')]['id'],'ContactId':_0x43d9b3[_0x628d('0xad')],'AttachmentId':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0]['id']})[_0x628d('0x1f')](function(_0x37d8fa){_0x43d9b3[_0x628d('0xae')]['Messages']=[];_0x43d9b3[_0x628d('0xae')][_0x628d('0xab')][_0x628d('0x8e')](_0x37d8fa['dataValues']);return _0x43d9b3;});})[_0x628d('0x1f')](function(_0x223ca1){respondWithRpcPromise(_0x628d('0xaf'),'SendFax',{'FaxAccountId':_['isNil'](_0x318590[_0x628d('0x50')]['id'])?undefined:_0x318590['params']['id'],'path':_[_0x628d('0xa4')](_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0][_0x628d('0x8')])?undefined:_0x318590['body'][_0x628d('0x9f')][0x0][_0x628d('0x8')],'fax':_[_0x628d('0xa4')](_0x318590[_0x628d('0x58')]['to'][0x0])?undefined:_0x318590['body']['to'][0x0],'AttachmentId':_0x318590[_0x628d('0x58')][_0x628d('0x9f')][0x0]['id']},client9002)[_0x628d('0x1f')](function(_0x1b9f4e){logger[_0x628d('0x20')]('SendFaxRpc,\x20%s',_0x1b9f4e);})[_0x628d('0x2a')](function(_0xee71bb){logger[_0x628d('0x20')](_0x628d('0xb0'),_0xee71bb);});return _0x223ca1;})['then'](respondWithResult(_0x454f1a,null))[_0x628d('0x2a')](handleError(_0x454f1a,null));};exports[_0x628d('0xb1')]=function(_0x2aac5b,_0x2225e8,_0x3110e7){return db['FaxAccount'][_0x628d('0x51')]({'where':{'id':_0x2aac5b[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x2225e8,null))['then'](function(_0xb80309){if(_0xb80309){return _0xb80309[_0x628d('0xb1')](_0x2aac5b[_0x628d('0x58')][_0x628d('0x65')],_['omit'](_0x2aac5b[_0x628d('0x58')],[_0x628d('0x65'),'id'])||{})['spread'](function(_0x1445af){for(var _0x1709e1=0x0;_0x1709e1<_0x2aac5b['body'][_0x628d('0x65')][_0x628d('0x46')];_0x1709e1+=0x1){socket[_0x628d('0xb2')]('userFaxAccount:save',{'UserId':_0x2aac5b['body'][_0x628d('0x65')][_0x1709e1],'FaxAccountId':_0x2aac5b[_0x628d('0x50')]['id']});}return _0x1445af;});}})[_0x628d('0x1f')](respondWithResult(_0x2225e8,null))[_0x628d('0x2a')](handleError(_0x2225e8,null));};exports[_0x628d('0xb3')]=function(_0x1e2430,_0xd6ca28,_0x5ac0ba){return db[_0x628d('0x3b')]['find']({'where':{'id':_0x1e2430[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0xd6ca28,null))[_0x628d('0x1f')](function(_0x2f5029){if(_0x2f5029){return _0x2f5029[_0x628d('0xb3')](_0x1e2430[_0x628d('0x41')][_0x628d('0x65')])[_0x628d('0x1f')](function(){if(_[_0x628d('0xb4')](_0x1e2430[_0x628d('0x41')][_0x628d('0x65')])){for(var _0x4cb9d1=0x0;_0x4cb9d1<_0x1e2430[_0x628d('0x41')][_0x628d('0x65')]['length'];_0x4cb9d1+=0x1){socket[_0x628d('0xb2')](_0x628d('0xb5'),{'UserId':Number(_0x1e2430[_0x628d('0x41')][_0x628d('0x65')][_0x4cb9d1]),'FaxAccountId':Number(_0x1e2430[_0x628d('0x50')]['id'])});}}else{socket[_0x628d('0xb2')](_0x628d('0xb5'),{'UserId':Number(_0x1e2430[_0x628d('0x41')][_0x628d('0x65')]),'FaxAccountId':Number(_0x1e2430[_0x628d('0x50')]['id'])});}});}})[_0x628d('0x1f')](respondWithStatusCode(_0xd6ca28,null))[_0x628d('0x2a')](handleError(_0xd6ca28,null));};exports['getAgents']=function(_0xc9b174,_0x3272fa,_0x9f4422){var _0x103a82={};var _0x2c4a1a={};var _0x51920a;var _0x36865a;return db[_0x628d('0x3b')][_0x628d('0x5f')]({'where':{'id':_0xc9b174[_0x628d('0x50')]['id']}})[_0x628d('0x1f')](handleEntityNotFound(_0x3272fa,null))[_0x628d('0x1f')](function(_0x3aef95){if(_0x3aef95){_0x51920a=_0x3aef95;_0x2c4a1a['model']=_[_0x628d('0x42')](db[_0x628d('0x71')]['rawAttributes']);_0x2c4a1a[_0x628d('0x41')]=_[_0x628d('0x42')](_0xc9b174['query']);_0x2c4a1a[_0x628d('0x4a')]=_['intersection'](_0x2c4a1a[_0x628d('0x40')],_0x2c4a1a[_0x628d('0x41')]);_0x103a82['attributes']=_[_0x628d('0x43')](_0x2c4a1a[_0x628d('0x40')],qs[_0x628d('0x45')](_0xc9b174[_0x628d('0x41')][_0x628d('0x45')]));_0x103a82[_0x628d('0x44')]=_0x103a82['attributes'][_0x628d('0x46')]?_0x103a82['attributes']:_0x2c4a1a['model'];_0x103a82['order']=qs[_0x628d('0x48')](_0xc9b174[_0x628d('0x41')][_0x628d('0x48')]);_0x103a82[_0x628d('0x49')]=qs[_0x628d('0x4a')](_[_0x628d('0x6e')](_0xc9b174[_0x628d('0x41')],_0x2c4a1a[_0x628d('0x4a')]));if(_0xc9b174[_0x628d('0x41')][_0x628d('0x4b')]){_0x103a82[_0x628d('0x49')]=_[_0x628d('0x4c')](_0x103a82[_0x628d('0x49')],{'$or':_[_0x628d('0x3a')](_0x103a82['attributes'],function(_0x310e1d){var _0xbf2189={};_0xbf2189[_0x310e1d]={'$like':'%'+_0xc9b174[_0x628d('0x41')][_0x628d('0x4b')]+'%'};return _0xbf2189;})});}_0x103a82=_['merge']({},_0x103a82,_0xc9b174[_0x628d('0x4e')]);return _0x51920a[_0x628d('0xb6')](_0x103a82);}})['then'](function(_0x147902){if(_0x147902){_0x36865a=_0x147902['length'];if(!_0xc9b174[_0x628d('0x41')]['hasOwnProperty'](_0x628d('0x47'))){_0x103a82[_0x628d('0x2f')]=qs[_0x628d('0x2f')](_0xc9b174['query'][_0x628d('0x2f')]);_0x103a82[_0x628d('0x2e')]=qs[_0x628d('0x2e')](_0xc9b174[_0x628d('0x41')]['offset']);}return _0x51920a[_0x628d('0xb6')](_0x103a82);}})[_0x628d('0x1f')](function(_0x279003){if(_0x279003){return _0x279003?{'count':_0x36865a,'rows':_0x279003}:null;}})['then'](respondWithResult(_0x3272fa,null))['catch'](handleError(_0x3272fa,null));};
\ No newline at end of file